|
Subject: [xsl] filtering problem From: Adrian Herscu <adrian.herscu@xxxxxxxxx> Date: Thu, 17 Jun 2010 11:54:28 +0300 |
<?xml version="1.0" encoding="UTF-8"?>
<batch name="level1">
<command src="1" />
<command src="2" failed="true()" />
<command src="3" />
<command src="4" failed="true()" />
<batch name="level2">
<command src="10" />
<command src="11" failed="true()" />
<command src="12" />
<batch name="level3">
<command src="20" />
<command src="21" failed="true()" />
<command src="22" />
</batch>
<command src="30" />
<command src="31" failed="true()" />
<command src="32" />
</batch>
</batch> <xsl:output method="xml" indent="yes" encoding="UTF-8"
media-type="text/xml" xalan:indent-amount="2" /> <xsl:template match="/">
<xsl:apply-templates />
</xsl:template> <!--
FIXME: batches are matched even though there is a prior failed
command or batch containing a failed command
-->
<xsl:template match="batch">
<batch name="{@name}">
<xsl:apply-templates />
</batch>
</xsl:template> <!-- match only the first failing command -->
<xsl:template match="command[@failed=true()][1]">
<failed-command src="{@src}" />
</xsl:template>
</xsl:stylesheet><?xml version="1.0" encoding="UTF-8"?> <batch xmlns:xalan="http://xml.apache.org/xalan" name="level1"> <failed-command src="2" /> <batch name="level2"> <failed-command src="11" /> <batch name="level3"> <failed-command src="21" /> </batch> </batch> </batch>
<?xml version="1.0" encoding="UTF-8"?> <batch xmlns:xalan="http://xml.apache.org/xalan" name="level1"> <failed-command src="2" /> </batch>
<?xml version="1.0" encoding="UTF-8"?>
<batch name="level1">
<batch name="level2">
<batch name="level3">
<failed-command src="21" />
</batch>
</batch>
</batch>Thanks for your help, Adrian.
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] An unintended incompatibi, Michael Dykman | Thread | Re: [xsl] filtering problem, Michael Kay |
| RE: [xsl] XSL Processing to avoid r, Fabien Tillier | Date | Re: [xsl] XSL Processing to avoid r, Michael Kay |
| Month |