[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Select nodes with an attribute but not all the nodes
Subject: [xsl] Select nodes with an attribute but not all the nodes From: <mysrdr-wrk@xxxxxxxxx> Date: Fri, 19 May 2006 09:05:34 -0700 (PDT) |
I am making an XML to XML transform using XSLT 2.0 and Saxon 8B. I need to select certain nodes based on an attribute, but when I find a node without the attribute I want to stop selecting nodes even if subsequent siblings have the attribute. <level2> <name>box</name> <number>1234</number> </level2> <level2> <name attachpart=1>washer</name> <number>234</number> </level2> <level2> <name attachpart=1>screw</name> <number>345</number> </level2> <level2> <name attachpart=1>bolt</name> <number>456</number> </level2> <level2> <name>nameplate</name> <number>9876</number> </level2> <level2> <name>switch</name> <number>7654</number> </level2> <level2> <name attachpart=1>screw</name> <number>345</number> </level2> The washer screw and bold are attaching parts for the box. I need to output these in an <attachingPart> element. <record> <name>box</name> <attachingPart>234 345 456</attachingPart> </record> Depending on how I approach the code, I get nothing or just the washer or I get *all* of the parts that have the attachpart attribute. Is there some way to say stop selecting attachpart nodes when a level2 doesnt have the attribute? Its sounds so simple but Im not getting anywhere with it. I've been reading both Michael and Jeni and checking the archives. Some things look close but I get the same results. The answer is probably right in front of my face but Ive been looking at it so long I cant see the forest for the trees. Regards, Hermy
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] using trax to write files, Michael Kay | Thread | RE: [xsl] Select nodes with an attr, Michael Kay |
Re: [xsl] WordML Question and norma, David Carlisle | Date | RE: [xsl] WordML Question and norma, Michael Kay |
Month |