|
Subject: Re: [xsl] How to perse the whole source document From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Sat, 26 May 2001 09:12:38 +0100 |
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>
</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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Convert XML elements with, Xiaocun Xu | Thread | RE: [xsl] How to perse the whole so, Mohammed Rahman |
| Re: [xsl] XSL List, Nikolai Grigoriev | Date | RE: [xsl] javax.xml.transform: proh, Julian Reschke |
| Month |