Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Re: trying to build an xpath query...

Reply
Thread Tools

Re: trying to build an xpath query...

 
 
Michael Dahlquist
Guest
Posts: n/a
 
      07-09-2003
Marrow -

This helps a ton. Perfect. Of course my example didn't end up being
quite accurate, but that just meant I had to figure the rest out on my
own. It's better that way. Thanks for your help -

Michael



But if you want to include the skipped <b> elements as being those that
are
part of the preceding <b> with a 'marker-' then you need to tweak the
key a
bit too, e.g.

== XSL2 =====================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" indent="yes"/>
<xsl:key name="kBGrouped" match="a/*[not(self::b) or
self::b[not(m/@id[starts-with(.,'marker-')])]]"
use="generate-id(preceding-sibling::b[m/@id[starts-with(.,'marker-')]][1
])"/
>

<xsl:template match="a">
<html>
<body>
<xsl:apply-templates select="b[m/@id[starts-with(.,'marker-')]]"/>
</body>
</html>
</xsl:template>

<xsl:template match="b">
<h2>
<xsl:text>B title: </xsl:text>
<xsl:value-of select="."/>
</h2>
<!-- now do all the elements following this <b> -->
<xsl:apply-templates select="key('kBGrouped',generate-id())"
mode="after-b"/>
</xsl:template>

<xsl:template match="*" mode="after-b">
<div>
<xsl:text>Element: </xsl:text>
<xsl:value-of select="name()"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="."/>
<xsl:text>)</xsl:text>
<!-- if you want to process the children of the elements -->
<!-- following the <b> then do an <xsl:apply-templates> -->
<!-- here and provide templates for them. -->
</div>
</xsl:template>
</xsl:stylesheet>
== end of XSL2 ==============================

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI vvcd Computer Support 0 09-25-2004 01:38 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM
Re: trying to build an xpath query... Michael Dahlquist XML 0 07-07-2003 02:37 PM
trying to build an xpath query... Michael Dahlquist XML 0 07-01-2003 08:21 PM



Advertisments