|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Converting attribute value to XML!
At 2004-01-23 15:28 +0000, Rui Alberto L." Gonçalves wrote:
I have a document that looks like: That isn't well-formed so it isn't XML ... do you mean <result> <filed name="xpto"><elem>Hello</elem></filed> </result> If so, it is a small change to your stylesheet: I tried: You are missing the preservation of the name attribute: <xsl:copy-of select="@name"/> <xsl:value-of select ="@value"/> Change the above to: <xsl:value-of disable-output-escaping="yes" select="@value"/> </xsl:element> </xsl:template> Resolved? The entities represent text characters and in your old stylesheet they went out as text characters so they had to be escaped. By turning off escaping you get what you want, but two caveats: (1) - a processor is not obliged to respect d-o-e= (2) - you can produce a non-well-formed result that isn't XML if you
have "bad" data in your text of your inputIf you avoid d-o-e= then your output will *always* be well-formed XML. I hope this helps. .................... Ken t:\ftemp>type rui.xml <result> <filed name="xpto" value="<elem>Hello<elem>"/> </result> t:\ftemp>type rui.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="*">
<xsl:element name="{name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template><xsl:template match="filed"> <xsl:element name="filed"> <xsl:copy-of select="@name"/> <xsl:value-of select ="@value" disable-output-escaping="yes"/> </xsl:element> </xsl:template> </xsl:stylesheet> t:\ftemp>saxon rui.xml rui.xsl <?xml version="1.0" encoding="utf-8"?><result> <filed name="xpto"><elem>Hello<elem></filed> </result> t:\ftemp>
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








