Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xslt transformation problem

Status
Not open for further replies.

frenchxmlnewbie

Technical User
Sep 21, 2009
2
0
0
FR
Hello

I would like to make the following transformation using xslt:
Source:
<code>
<ap:Topic DOId="DptmmZv5qkeUEAjLtRkqVA==">
<ap:Text PlainText="Texte du topic">
<ap:Font Bold="yes"/>
</ap:Text>
</ap:Topic>
Result:
<code>
<node ID="DptmmZv5qkeUEAjLtRkqVA" TEXT="Texte du topic">
<font BOLD="true"/>
</node>
</code>

I use the following xslt source:
<code>
<xsl:template match="ap:Topic">
<node>
<xsl:attribute name="TEXT">
<xsl:value-of select="./ap:Text/@PlainText" />
</xsl:attribute>
<xsl:apply-templates select="./ap:Text" />
</node>
</xsl:template>
<xsl:template match="ap:Text">
<xsl:apply-templates select="./ap:Font" />
</xsl:template>
<xsl:template match="ap:Font">
<xsl:element name="font">
<xsl:attribute name="BOLD">
<xsl:value-of select="@Bold"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
</code>

Problem is: the template ap:Text erase all the content of attribute TEXT, as if I could not parse element "Text" twice.

Please help.
 
I don't see the namespace and its prefix defined anywhere. It shouldn't work without.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top