|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to create a node set that excludes some desce
Hi Rush,
Please try this XSL -
It is variation of identity transform..
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
<!-- include only 1st y , and exclude all z -->
<xsl:template match="y[ancestor::y or preceding::y] |
z" />
</xsl:stylesheet>
Regards,
Mukul
--- Rush Manbert <rush@xxxxxxxxxxx> wrote:
> Hi all,
>
> My first post here and I want to start by saying how
> much I appreciate
> the big FAQ, the Jeni site, etc. It has all helped
> me tremendously.
>
> I can't find an answer to this one, though, so here
> goes...
>
> My XML doc has this basic structure:
> <a>
> <b>
> <c>
> <!-- This is the section of interest -->
> </c>
> </b>
> </a>
>
> The <c> element can contain any combination of
> elements <d> through <z>.
> Elements <y> and <z> have special uses.
>
> I want to create a global variable that contains the
> result tree
> fragment contained within element <c>, with the
> following restrictions:
> I only want to include the first <y> element that is
> contained within
> <c>, no matter where it occurs. There may be no <y>
> elements present.
> I want to exclude all <z> elements that are
> contained within <c>, no
> matter where they occur. Again, there may be none
> present.
>
> Later on in my stylesheet, I use exslt:node-set() on
> the variable and
> process the node set.
>
> For instance, given this source:
> <a><b><c>
> <d>
> <z>
> <g />
> </d>
> <q>
> <r>
> <y />
> <z />
> </r>
> <y />
> <q>
> <y>
> </c></b></a>
>
> I want the selection to contain this:
> <a><b><c>
> <d>
> <g />
> </d>
> <q>
> <r>
> <y />
> </r>
> <q>
> </c></b></a>
>
> (<z> elements are gone, only the first <y> element
> remains.)
>
> I have tried many variations on the select portion
> of the variable
> definition. I can filter the immediate children of
> <c>, OR the second
> level children, etc., but I can't seem to come up
> with anything that
> handles <y> and <z> appearing at any depth in the
> descendant tree.
>
> I'm prepared to be humiliated by some obvious
> solution... Can anyone
> please help?
>
> Thanks,
> Rush
>
>
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
|
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
|

Cart








