[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] ANN: XML Encoded XPath 0.2 (Stylesheet)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" /> <xsl:template match="/"> <xsl:for-each select="/XEXPaths/*"> ---------------------------------------------- <xsl:apply-templates select="." /> </xsl:for-each> </xsl:template> <xsl:template match="variable">$<xsl:value-of select="text()" /></xsl:template> <xsl:template match="literal">'<xsl:value-of select="text()" />'</xsl:template> <xsl:template match="number"><xsl:value-of select="text()" /></xsl:template> <xsl:template match="function"> <xsl:for-each select="@nsURI">{<xsl:value-of select="."/>}:</xsl:for-each> <xsl:value-of select="@name"/>(<xsl:apply-templates select="*[1]" /><xsl:for-each select="*[position()!=1]">,<xsl:apply-templates select="." /></xsl:for-each>)</xsl:template> <!-- OPERATORS --> <xsl:template match="union">(<xsl:apply-templates select="*[1]" /> | <xsl:apply-templates select="*[2]" />)</xsl:template> <!-- boolean --> <xsl:template match="and">(<xsl:apply-templates select="*[1]" /> and <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="or">(<xsl:apply-templates select="*[1]" /> or <xsl:apply-templates select="*[2]" />)</xsl:template> <!-- comparison --> <xsl:template match="eq">(<xsl:apply-templates select="*[1]" /> = <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="ne">(<xsl:apply-templates select="*[1]" /> != <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="lt">(<xsl:apply-templates select="*[1]" /> < <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="gt">(<xsl:apply-templates select="*[1]" /> > <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="le">(<xsl:apply-templates select="*[1]" /> <= <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="ge">(<xsl:apply-templates select="*[1]" /> >= <xsl:apply-templates select="*[2]" />)</xsl:template> <!-- arithmetic --> <xsl:template match="add">(<xsl:apply-templates select="*[1]" /> + <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="sub">(<xsl:apply-templates select="*[1]" /> - <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="mul">(<xsl:apply-templates select="*[1]" /> * <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="div">(<xsl:apply-templates select="*[1]" /> div <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="mod">(<xsl:apply-templates select="*[1]" /> mod <xsl:apply-templates select="*[2]" />)</xsl:template> <xsl:template match="neg">(-<xsl:apply-templates select="*[1]" />)</xsl:template> <xsl:template match="compose"> <!-- first step --> <xsl:for-each select="*[1]"><xsl:apply-templates select="." /></xsl:for-each> <!-- 2nd to Nth steps --> <xsl:for-each select="*[position()!=1]"> <xsl:choose> <xsl:when test="self::filter"> <xsl:text>[</xsl:text> <xsl:apply-templates select="*" /> <xsl:text>]</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>/</xsl:text> <xsl:apply-templates select="." /> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> <!-- AXES --> <xsl:template match="attribute"> <xsl:text>attribute::</xsl:text> <xsl:call-template name="AXIS" /> </xsl:template> <xsl:template match="child"> <xsl:text>child::</xsl:text> <xsl:call-template name="AXIS" /> </xsl:template> <xsl:template match="ancestor">ancestor::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="ancestor-of-self">ancestor-or-self::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="descendant">descendant::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="descendant-or-self">descendant-or-self::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="following">following::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="following-sibling">following-sibling::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="namespace">namespace::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="parent">parent::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="preceding">preceding::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="preceding-sibling">preceding-sibling::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="self">self::<xsl:call-template name="AXIS" /></xsl:template> <xsl:template match="root">/</xsl:template> <xsl:template match="root[following-sibling::*]"></xsl:template> <xsl:template name="AXIS"> <xsl:choose> <xsl:when test="@type='comment'">comment()</xsl:when> <xsl:when test="@type='node'">node()</xsl:when> <xsl:when test="@type='text'">text()</xsl:when> <xsl:when test="@type='processing-instruction'">processing-instruction(<xsl:value-of select="@name"/>)</xsl:when> <xsl:otherwise> <!-- nametest or * --> <xsl:for-each select="@nsURI">{<xsl:value-of select="."/>}:</xsl:for-each> <xsl:choose> <xsl:when test="normalize-space(text())!=''"> <xsl:value-of select="normalize-space(text())"/> </xsl:when> <xsl:otherwise>*</xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- ABBREVIATED VERSIONS --> <xsl:template match="descendant-or-self[@type='node'][not(*)][preceding-sibling::*][following-sibling::*]"> </xsl:template> <xsl:template match="parent[@type='node']">..</xsl:template> <xsl:template match="self[@type='node']">.</xsl:template> <xsl:template match="attribute"> <xsl:text>@</xsl:text> <xsl:call-template name="AXIS" /> </xsl:template> <xsl:template match="child"> <xsl:call-template name="AXIS" /> </xsl:template> </xsl:stylesheet> _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|