This is a post on the little pains I am sure most people have endured while working with Java and XML from different sources, with 'funny' characters...
If you use a FileWriter instead of a FileOutputStream it will use your OS encoding (So cp1252, ISO-8859-1 or US-ASCII and not UTF-8... ):
A way to ensure that you are using UTF-8 is:
If you are reading XML from a stream, it is probably safer to do something like:
When validating a schema note the .getBytes("UTF-8"):
When marshalling (Use a stream rather than a writer):
Lastly if you are getting XML from some unknown source there are some chars that are outside the legal XML Unicode limits that you can not encode. To remove those:
Code below from another blog :
Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts
Wednesday, August 24, 2011
Monday, February 14, 2011
Validate XML against its XSD
Just a quick code snippet for possible future reference. How to validate a XML against it's XSD.
Subscribe to:
Posts (Atom)
Building KubeSkippy: Learnings from a thought experiment
So, I got Claude Code Max and I thought of what would be the most ambitious thing I could try "vibe"? As my team looks after Kuber...
-
I have been messing around with AWS on little side projects and experiments for about the last year. I did find it quite a daunting experien...
-
I make no claim to be a "computer scientist" or a software "engineer", those titles alone can spark some debate, I regar...