Pregunta

I have this XML file

<test>&#13; &#xD; &lt;</test>

and i am tranforming it with the java code below, the xslt file just makes a copy of the xml

public class XMLTransform {

    public static void main(String[] args) {

        try {
            StreamSource source = new StreamSource(new File("file.xml"));
            StreamSource stylesource = new StreamSource(new File("trans.xsl"));
            SAXTransformerFactory transformFactory = (SAXTransformerFactory) TransformerFactory.newInstance(); 
            Transformer transformer = transformFactory.newTransformer(stylesource);
            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");         
            transformer.setOutputProperty(OutputKeys.INDENT, "yes"); 
            StreamResult result = new StreamResult(System.out);
            transformer.transform(source,result);
        }
        catch (Exception e) {
            e.printStackTrace();
        }

    }
}

my problem is that java replaces the canonical carriage return &#xD with the &#13 which is the ascii character.

Any help on how to preserve the canonical name for the carriage return?

¿Fue útil?

Solución 2

I found that SAXON transformer does not make this modification. thanks for your answers.

Otros consejos

you do realize that those are the exact same character, just in decimal form (&#13) vs. hexidecimal form (&#xD) (nothing to do w/ ascii per se).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top