Hi,
I am just using this Java code:
----------
//Read it => automatically converts it to UTF-8
DocumentBuilder Factory factory = DocumentBuilder Factory
.newInstance();
DocumentBuilder builder = factory.newDocu mentBuilder();
document = builder.parse(n ew File(fileName)) ;
TransformerFact ory tFactory = TransformerFact ory.newInstance ();
Transformer transformer = tFactory.newTra nsformer();
//Save it
DOMSource source = new DOMSource(docum ent);
File file = new File(fileName);
StreamResult result = new StreamResult(fi le);
transformer.tra nsform(source, result);
----------
Works fine, but the big Problem is that it orders the attributes of
elements in an alpabetic way. And I don't see a possibility right now to
avoid that.
Before: <concept name="Animal" display="always " level="1">
After: <concept display="always " level="1" name="Animal">
My aim is to:
1. Do an utomatic encoding conversion to UTF-8 of an xml document
2. change some attributes in the root element (Check for a certain
schema location etc...) of this xml document
Do you have any practical solutions for that that preserve the order of
attributes within elements (using sax...)?
Thanks a lot,
Raphael
I am just using this Java code:
----------
//Read it => automatically converts it to UTF-8
DocumentBuilder Factory factory = DocumentBuilder Factory
.newInstance();
DocumentBuilder builder = factory.newDocu mentBuilder();
document = builder.parse(n ew File(fileName)) ;
TransformerFact ory tFactory = TransformerFact ory.newInstance ();
Transformer transformer = tFactory.newTra nsformer();
//Save it
DOMSource source = new DOMSource(docum ent);
File file = new File(fileName);
StreamResult result = new StreamResult(fi le);
transformer.tra nsform(source, result);
----------
Works fine, but the big Problem is that it orders the attributes of
elements in an alpabetic way. And I don't see a possibility right now to
avoid that.
Before: <concept name="Animal" display="always " level="1">
After: <concept display="always " level="1" name="Animal">
My aim is to:
1. Do an utomatic encoding conversion to UTF-8 of an xml document
2. change some attributes in the root element (Check for a certain
schema location etc...) of this xml document
Do you have any practical solutions for that that preserve the order of
attributes within elements (using sax...)?
Thanks a lot,
Raphael