I have an XML document as follows:
Code:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="ZoneType_TEXT.xsl"?>
<ZoneContent>
<paragraph style="Heading2" link="http://www.sqlservercentral.com" linktitle="Sql Server Central" window="1">This is a test</paragraph>
<paragraph>This is another</paragraph>
<paragraph>This is another</paragraph>
</ZoneContent>
What I want to do is to itterate through the paragraph tags and convert them into HTML so that Heading 2 wraps everything up in HTML H2 tags.
If There is a link then there will be an <h2><a href="http://www.sqlservercentral.com" title="Sql Server Central" target="1">This is a test paragraph</a></h2>
My XSLT looks as follows
Code:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:for-each select="ZoneContent/paragraph">
<xsl:choose>
<xsl:when test="@style='Heading1'">
<xsl:element name="h1">
<xsl:appy-templates select="."/>
</xsl:element>
</xsl:when>
<xsl:when test="@style='Heading2'">
<xsl:element name="h2">
<xsl:appy-templates select="."/>
</xsl:element>
</xsl:when>
<xsl:when test="@style='Heading3'">
<xsl:element name="h3">
<xsl:appy-templates select="."/>
</xsl:element>
</xsl:when>
<xsl:when test="@style='Heading4'">
<xsl:element name="h4">
<xsl:appy-templates select="."/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="p">
<xsl:appy-templates select="."/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template match=".">
<xsl:choose>
<xsl:when test="@link">
<xsl:element name="a">
<xsl:attribute name="href" >
<xsl:value-of select="@link" />
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="@linktitle" />
</xsl:attribute>
<xsl:attribute name="target">
<xsl:value-of select="@window" />
</xsl:attribute>
<xsl:value-of select="current()"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="current()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
but it gives errors saying that I can't post at this time.
I am really banging my head against this and should be grateful for any help that can be given.