Expand|Select|Wrap|Line Numbers
- <?xml version="1.0" encoding="UTF-8" ?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
- xmlns:TP="urn:TemplateParser">
- <xsl:template match="/">
- <html>
- <body>
- <h3>DATA Tag Replacement Example</h3>
- <p>
- Name = <b><xsl:value-of select="TP:GetValue('NAME')"/></b>
- </p>
- <h3>CONDITION Tag Replacement Example</h3>
- <p>I drive
- <xsl:if test="TP:IsConditionTrue('HONDA')"> an Accord.</xsl:if>
- <xsl:if test="TP:IsConditionTrue('TOYOTA')"> a Camry.</xsl:if>
- </p>
- <h3>REPEAT Tag Replacement Example</h3>
- <p>Friends characters...
- <table>
- <tr><th>NAME</th><th>GENDER</th></tr>
- <xsl:for-each select="TP:IsRecordAvailable('Friends')-->
- <tr>
- <td><xsl:value-of select="TP:GetRepeatValue('Friends', 'Name')"/></td>
- <td><xsl:value-of select="TP:GetRepeatValue('Friends', 'Gender')"/></td>
- </tr>
- </xsl:for-each>
- </table>
- </p>
- </body>
- </html>
- </xsl:template>
- </xsl:stylesheet>
I am doing a Transform with a dummy XML file (no data), the above XSL file and the TP class like this:
Expand|Select|Wrap|Line Numbers
- XPathDocument xmlDoc = new XPathDocument( xmlDocName );
- XslTransform xslt = new XslTransform();
- xslt.Load( xslDocName );
- XsltArgumentList xsltArgList = new XsltArgumentList();
- TP tpObj = new TP();
- xsltArgList.AddExtensionObject( "urn:TemplateParser", tpObj );
- XmlTextWriter writer = new XmlTextWriter( output, null );
- xslt.Transform( xmlDoc, xsltArgList, writer, null );
TIA