adam@jeeni.co.uk Posted March 28, 2007 Share Posted March 28, 2007 Hello all,I’ve got a problem. I’ve got an xml file (output of JUnit), and a properties file that the system uses to configure database connections etc, and it also has some sql in it. We want to display this properties file as part of the JUnit HTML report. So we edited the xsl file. And...Put a <!ENTITY thefile SYSTEM 'properties.file'>at the top of our xsl file and latter on in the approperate place we put:<p>& thefile;</p>The problem is this dosn't work because the sql statement in the props file contains a less-than operator <. And this screws up the parsing.We tried <![CDATA[ &thefile; ]]> but that didn’t work either. We tried<xsl:text disable-output-escaping="yes"> &thefile;</xsl:text>with values yes and no, and that didn’t work.We tried using <xsl:output cdata-section-elements="cdatatext"/> at the top of the xsl file (child of stylesheet), and then:<cdatatext> &thefile;</cdatatext>And yup, you guessed it. That didn’t work either.In the end we used the ant <replace> target to parse the file and replace the < with a < prior to xsl parsing. Not a good solution.We also considered writing a Java class to encode the props file and then invoke it via an Xalan extension, but also thought this was not an ideal solution either.Dose anyone in the community know how this can be done simply? Best answer gets a postcard from the British West-Country.Thanksadam Link to comment Share on other sites More sharing options...
boen_robot Posted March 28, 2007 Share Posted March 28, 2007 Unfrortunatly, there is no way around editing the source text file to conform to the XML well formdness rules. However, instead of replacing every special entity, you can just surround the whole contents of the text file in CDATA, making the contents of the 'properties.file' be: <![CDATA[copy the original text here]]> Not the best solution, but still feasable and more efficient.By the way, if you could install Saxon or any other XSLT 2.0 processor- go ahead. XSLT 2.0 has the new unparsed-text() function and regular expression functions that can handle plain text files. I mean... they were MADE to handle plain text files, unlike the entities which were made to hold small amounts of text or XML based data. Link to comment Share on other sites More sharing options...
adam@jeeni.co.uk Posted March 29, 2007 Author Share Posted March 29, 2007 Thanks Gobby. I'll look into Saxon, and see what else we can do. Thanks again for the tip.Adam Link to comment Share on other sites More sharing options...
boen_robot Posted March 29, 2007 Share Posted March 29, 2007 My Nickname is not Gobby (and you're the second person to get it wrong). Look at the topic it references.Anyway, you're welcomed. Link to comment Share on other sites More sharing options...
adam@jeeni.co.uk Posted March 30, 2007 Author Share Posted March 30, 2007 Sorry boen_robot,Will be more careful next timecheerzAdam Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now