[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to perse the whole source document

Subject: Re: How to perse the whole source document
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 26 May 2001 09:12:38 +0100
xml perse
Hi Mo,

The XSLT is parsing the entire source document, it's just that you're
only accessing part of it.  You're stepping through the content of a
section element one node at a time in order to group the para
elements.  However, when you find a para element, you're only moving
on to the next para element with the same name - if there isn't one
you stop, so the section elements afterwards are ignored.

Perhaps it'd be better to try a different approach - apply templates
to everything and test within a template what you need to do.  So,
when you find a section element, create a sid and apply templates to
everything inside it:

<xsl:template match="section">
   <sid>
      <xsl:apply-templates />
   </sid>
</xsl:template>

When you find a para element, test whether its preceding sibling is a
para element with the same name as it has - if it is, do nothing, if
it isn't, do all the funky stuff you want to do with the para element:

<xsl:template match="para">
   <xsl:variable name="as" select="@name" />
   <xsl:if test="preceding-sibling::para[1]/@name != $as">
      <text name="{$as}">
         <xsl:apply-templates select="." mode="content" />
         <xsl:copy-of select="document('doc2.xml')
            /TableName/RecordName[normalize-space(name) = $as]
            /*[not(self::name)]" />
      </text>
   </xsl:if>
</xsl:template>

<xsl:template match="para" mode="content">
   <xsl:copy-of select="node()" />
   <xsl:text>&#xa;</xsl:text>
   <xsl:apply-templates mode="content"
      select="following-sibling::*[1][@name = current()/@name]" />
</xsl:template>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.