Project

Profile

Help

Maintenance: Planio will be observing a scheduled maintenance window this Sunday, November 10, 2024 from 20:00 UTC until 21:00 UTC to perform important network maintenance in our primary data center. Your Planio account will be unavailable for a few minutes during this maintenance window.

Preserving 
 characters

Added by Anonymous almost 19 years ago

Legacy ID: #3455018 Legacy Poster: gsorak (gsorak)

I am trying to read visio XML file (vdx), do some XSLT tranformations and write it out for visio to display it again. In the process it has to preserve &#xA; characters from original file, e.g. <pp IX='1'/>&#xA;<cp IX='2'/> It should be writen as such (not translated into linefeed) In my current attempts &#xA; from the input file ends up as line feed character in the output, which causes visio warnings and some loss of formating. Is there a simple solution for preserving &#xA; across reading and writing XML file? Part of java code I used is shown below. I tried capturing in XSLT file cases where &#xA; is lost, but it is becoming messy. Thanks, Goran I was using code SAXBuilder parser = new SAXBuilder(); File visiofile = new File("C:\xx.xml"); Document visiodoc = parser.build(visiofile); ......... DocumentWrapper docw = new DocumentWrapper(document, null, new Configuration()); System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); TransformerFactory tfactory = TransformerFactory.newInstance(); Templates templates = tfactory .newTemplates(new StreamSource( "C:\test.xslt")); Transformer transformer = templates.newTransformer(); transformer.transform(docw, new StreamResult(System.out));


Replies (2)

RE: Preserving &amp;#xA; characters - Added by Anonymous almost 19 years ago

Legacy ID: #3455290 Legacy Poster: Michael Kay (mhkay)

&#xA; and the character with value 10 are equivalent ways of inputting a newline character, and in the information passed to Saxon by the XML parser there is no way of distinguishing them (this isn't a Saxon peculiarity, it's laid down by the specs). If you want to treat them differently (and I find it hard to understand why - no XML-aware application is going to treat them differently), the only way is to use a non-XML-aware process such as a Perl script to preprocess the input and turn the &#xa; references into something else. Michael Kay http://www.saxonica.com/

RE: Preserving &amp;#xA; characters - Added by Anonymous almost 19 years ago

Legacy ID: #3458840 Legacy Poster: gsorak (gsorak)

Thanks for the quick response. I suspected that this is the case, based on my limited reading of XML specs. It is just that I was trying to "please" MS Visio reading back XML files. It looks it doesn't like changes in special characters to their XML canonical form. Goran

    (1-2/2)

    Please register to reply