How to Handle Inline Markup Elements in XSLT
-
Say I have this XML Document:
<?xml version="1.0" encoding="UTF-16"?>
<?xml-stylesheet type="text/xsl" href="MyXsl.xsl"?>
<page>
<para>
Test paragraph.
</para><para> Test <link href="codeproject.com">link</link>. </para>
</page>
In XSLT, how would you change
<link href
into<a href
? I have this so far...<xsl:template match="/">
...
<xsl:for-each select="//para">
<xsl:call-template name="paragraph"/>
</xsl:for-each>
...
</xsl:template><xsl:template match="//para" name="paragraph">
<p>
<xsl:value-of select="."/>
</p>
</xsl:template>Thanks! I've tried Google, but couldn't find anything useful.
Fluent in VB, Attempts to speak C#, Python, English ;)
---
File Association in VB.Net
Creating Custom Controls: Casino Royale -
Say I have this XML Document:
<?xml version="1.0" encoding="UTF-16"?>
<?xml-stylesheet type="text/xsl" href="MyXsl.xsl"?>
<page>
<para>
Test paragraph.
</para><para> Test <link href="codeproject.com">link</link>. </para>
</page>
In XSLT, how would you change
<link href
into<a href
? I have this so far...<xsl:template match="/">
...
<xsl:for-each select="//para">
<xsl:call-template name="paragraph"/>
</xsl:for-each>
...
</xsl:template><xsl:template match="//para" name="paragraph">
<p>
<xsl:value-of select="."/>
</p>
</xsl:template>Thanks! I've tried Google, but couldn't find anything useful.
Fluent in VB, Attempts to speak C#, Python, English ;)
---
File Association in VB.Net
Creating Custom Controls: Casino RoyaleI hope the following will give you some ideas:
<?xml version="1.0"?> <page> <para> Test paragraph </para> <para> A good place to find source code is <link href="http://www.codeproject.com">CodeProject</link> </para> </page> <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/page"> <xsl:apply-templates select="para"/> </xsl:template> <xsl:template match="para"> <p><xsl:apply-templates select="child::text() | link"/></p> </xsl:template> <xsl:template match="text()"> <xsl:value-of select="."/> </xsl:template> <xsl:template match="link"> <a href="{@href}"><xsl:value-of select="."/></a> </xsl:template> </xsl:stylesheet>
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
I hope the following will give you some ideas:
<?xml version="1.0"?> <page> <para> Test paragraph </para> <para> A good place to find source code is <link href="http://www.codeproject.com">CodeProject</link> </para> </page> <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/page"> <xsl:apply-templates select="para"/> </xsl:template> <xsl:template match="para"> <p><xsl:apply-templates select="child::text() | link"/></p> </xsl:template> <xsl:template match="text()"> <xsl:value-of select="."/> </xsl:template> <xsl:template match="link"> <a href="{@href}"><xsl:value-of select="."/></a> </xsl:template> </xsl:stylesheet>
"We make a living by what we get, we make a life by what we give." --Winston Churchill
Thanks a lot!
Fluent in VB, Attempts to speak C#, Python, English ;)
---
File Association in VB.Net
Creating Custom Controls: Casino Royale