Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Help - I'm losing newline when performing XSL Transform Help - I'm losing newline when performing XSL TransformTo: NULL Date: 10/1/2005 2:40:00 PM I'm trying to preserve the newline characters in my transformed XML
(read from a file) to provide a meaningful line number when validation
errors occur. However, my current method which performs an XSL
transform prior to validation is removing all the newlines. The XSL is
simply adding a namespace:
<xsl:stylesheet
xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"
version=3D"1.0"
xmlns=3D"urn:RegisteredUser-schema">
<!-- This will just set the namespace of the topmost object -->
<xsl:template match=3D"*">
<xsl:element name=3D"{local-name()}">
<xsl:apply-templates select=3D"@* | node()" />
</xsl:element>
</xsl:template>
<xsl:template match=3D"@*">
<xsl:copy-of select=3D"." />
</xsl:template>
</xsl:stylesheet>
The problem is that an input XML string which has newlines goes from:
<user>
<firstname>Joe</firstname>
<lastname>User</lastname>
</user>
to a string without newlines:
<user
xmlns=3D"urn:RegisteredUserschema"><firstname>Joe</firstname><lastname>User=
</=ADlastname></user>
So any subsequent validation failure states that an error occurred on
line 1. I would like to be able to preserve the newlines in the
original string representation of the file, so that the error message
displayed to the user is meaningful.=20
Thanks in advance
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
