Subject: Re: [xsl] Converting attribute value to XML! From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 23 Jan 2004 11:19:49 -0500 |
I have a document that looks like:
<result> <filed name="xpto" value="<elem>Hello<elem>"/> </result>
and I want to transform to : <result> <filed name="xpto">Hello</elem> </result>
<result> <filed name="xpto"><elem>Hello</elem></filed> </result>
I tried:
<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:value-of select ="@value"/>
</xsl:element> </xsl:template>
but entities are not resolved. Any idea?
(2) - you can produce a non-well-formed result that isn't XML if you have "bad" data in your text of your input
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>
-- Public courses: sign up for one or both soon to reserve your seat! Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Washington, DC: 2004-03-15 San Francisco, CA: 2004-03-22 Hong Kong, China: 2004-05-17 Bremen, Germany: 2004-05-24 World-wide on-site corporate, government & user group XML training
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Converting attribute value to, Rui Alberto L. | Thread | Re: [xsl] Converting attribute valu, Rui Alberto L. |
Re: [xsl] Accessing data from repea, Andrew Curry | Date | RE: [xsl] Converting attribute valu, Amuchastegui, Maria |
Month |