[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: selecting w:p nodes based on w:pStyle attributes
At 2006-03-27 16:41 -0500, Terry Ofner wrote:
I am trying to select w:p nodes based on w:pStyle attribute. ... The p:Style node is a child of the w:p node No, it is a descendant, it is not a child in your example. which I want to select and copy to the result tree. Here is an example of the XML: There you are matching on the descendant of w:p, not on w:p, yet your first sentence quoted above is that you are trying to select w:p ... but you don't say what you want done with the w:p that you select. I know that "w:p/w:pPr/w:pStyle[@w:val = 'NL']" works to select the particular attribute. No, that expression in a select= attribute selects w:pStyle based on the particular attribute, it does not select the attribute. For example, when I run the template below, I get repeated <w:pStyle w:val = "NL" > nodes in the result tree with nothing else. You don't say what you want to do with the w:p elements you said you wanted to select. Guessing what your needs might be, I suspect you want: <xsl:template match="w:p[w:pPr/w:pStyle/@w:val = 'NL']"> <!--do something here with w:p as current node--> </xsl:template> Your issue is that you don't want to walk away from what it is you want to select ... that means that you add the predicate to what you want to select, as I did in the above example. A synonymous match statement would also be: <xsl:template match="w:p[w:pPr/w:pStyle[@w:val = 'NL']]"> <!--do something here with w:p as current node--> </xsl:template> Notice in my answer to your earlier question that I did the work in the template that matches the node needed: http://www.biglist.com/lists/xsl-list/archives/200603/msg00735.html So the same applies above: match the node you want to work with by qualifying it with a predicate. Don't use "/" to walk away from the node. I hope this helps. . . . . . . . . . . . Ken
|
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
|