Escaping xml tag in XSLT -


i have input xml, say:

<myxml>     <myelement id="1" />     <myelement id="2" />     <myelement id="3" /> </myxml> 

i want create xslt creates output xml of different form, say:

<theirxml>     <theirelement id="1" />     <theirelement id="2" />     <theirelement id="3" /> </theirxml> 

since cannot create xslt tag inside tag (e.g. "<theirelement id="<xslt:...>" >" found way cdata follows (presented relevant part of xslt):

<xsl:for-each select="myxml/myelement">     <xsl:text><![cdata[<theirelement id="]]></xsl:text><xsl:value-of select="@name" /><xsl:text><![cdata[" />]]></xsl:text> </xsl:for-each> 

however produced output not contain "<theirelement ..." rather "&lt;theirelement ...". need output contain "<" , not "&lt;" (same goes ">" , "&gt;").

the reason, btw, because output process input program fails read xml when tags escaped "&lt;tag&gt;".

any appreciated!

here stylesheet desired transform:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">      <xsl:output encoding="utf-8" method="xml"/>      <xsl:template match="/">         <myxml>             <xsl:apply-templates/>         </myxml>     </xsl:template>      <xsl:template match="myelement">         <theirelement>             <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>         </theirelement>     </xsl:template>  </xsl:stylesheet> 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -