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.
Forums » Help »
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 

characters from original file, e.g. <pp IX='1'/>
<cp
IX='2'/> It should be writen as such (not translated into linefeed) In my current
attempts 
 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 
 across reading and writing XML file? Part of java code I used
is shown below. I tried capturing in XSLT file cases where 
 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));
Legacy ID: #3455290
Legacy Poster: Michael Kay (mhkay)

 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

 references into something else. Michael Kay
http://www.saxonica.com/
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
Please register to reply