[Home] [By Thread] [By Date] [Recent Entries]
At 2008-12-09 13:58 -0200, Alexandre Moraes wrote:
Hi guys,
The xml can come like this too: The following: preceding-sibling::node()[not(self::text())][1]/
self::processing-instruction('proc')says: "Get the preceding sibling nodes of any kind, looking only at the non-text nodes, then looking only at the first of those, checking that node is a processing instruction with the name 'proc'." I hope this helps. . . . . . . . . . . Ken T:\>type alexandre.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<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="//child2">
<xsl:choose>
<xsl:when test="preceding-sibling::node()[not(self::text())][1]/
self::processing-instruction('proc')">Yes!</xsl:when>
<xsl:otherwise>No!</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template></xsl:stylesheet>
T:\>type alexandre1.xml
<root>
<child1>
child 1
</child1>
<?proc?>
<child2>
child 2
</child2>
</root>T:\>xslt alexandre1.xml alexandre.xsl con
Yes!
T:\>type alexandre2.xml
<root>
<child1>
child 1
</child1>
<child2>
child 2
</child2>
</root>T:\>xslt alexandre2.xml alexandre.xsl con
No!
T:\>type alexandre3.xml
<root>
<?proc?>
<child1>
child 1
</child1>
<child2>
child 2
</child2>
</root>T:\>xslt alexandre3.xml alexandre.xsl con No! T:\>
|

Cart



