[Home] [By Thread] [By Date] [Recent Entries]
Hi Michael,
thanks for the help :) I tried to apply your idea on my template (written in XSL 1.0 + Xalan Extensions); here is what I got: The input xml:
<?xml version="1.0" encoding="UTF-8"?>
<procedure name="RunSomething">
<command src="10" />
<command src="11" />
<command src="12" />
<command src="13" />
<call name="DoFoo">
<command src="20" />
<command src="21" />
<command src="22" />
<call name="MakeFoo">
<command src="30" />
<command src="31" failed="true()" />
<command src="32" />
</call>
<command src="24" />
<command src="25" failed="true()" />
<call name="WriteFoo">
<command src="40" />
<command src="41" failed="true()" />
<command src="42" />
</call>
<command src="26" />
</call>
</procedure>The XSL: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="xalan"> <xsl:output method="xml" indent="yes" encoding="UTF-8"
media-type="text/xml" xalan:indent-amount="2" /><xsl:strip-space elements="*" /> <xsl:variable name="firstFailure" select="(//command[@failed=true()])[1]" /> <xsl:variable name="pathToFirstFailure" select="xalan:nodeset($firstFailure)/ancestor-or-self::*" /> <xsl:template match="command[@failed=true()]">
<failing-command src="{@src}" />
</xsl:template><xsl:template match="*[xalan:intersection(node(), xalan:nodeset($pathToFirstFailure))]"> <xsl:copy> <xsl:copy-of select="@*" /> <xsl:apply-templates /> </xsl:copy> </xsl:template> <xsl:template match="*" /> </xsl:stylesheet> The output:
<?xml version="1.0" encoding="UTF-8"?>
<procedure name="RunSomething">
<call name="DoFoo">
<call name="MakeFoo">
<failing-command src="31" />
</call>
<failing-command src="25" />
</call>
</procedure>My problem is with the <failing-command src="25" /> element; it should not be generated. How do I filter it out? Thanks, Adrian. On 6/17/2010 12:15 PM, Michael Kay wrote:
|

Cart



