This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: rendering marginal XML
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] rendering marginal XML
- From: "McNally, David" <David dot McNally at moodys dot com>
- Date: Fri, 26 Oct 2001 16:09:26 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
> > <msgSent>
> > <time>time sent</time>
> > <origin>me@here.com</origin>
> > <r>you@there.com</r>
> > <recieved>time recieved</recieved>
> > <status>Any error messages, etc</status>
> > <r>you2@there.com</r>
> > <recieved>time recieved</recieved>
> > <status>Any error messages, etc</status>
> > (this repeats for each recipient)
> > </msgSent>
> > (this repeats for each message)
> >
> > The problem is the <recieved> and <status> tags refer to the
> > imediately preceding <r> tag.
>
> If the structure is sufficiently regular you can add the necessary
> <recipient> element by doing
>
> <xsl:template match="r">
> <recipient>
> <name><xsl:value-of select="."/></name>
> <received><xsl:value-of
> select="following-sibling::recieved[1]"/></received>
> <status><xsl:value-of
> select="following-sibling::status[1]"/></status>
> </recipient>
> </xsl:template>
>
Or, to deal with missing Status elements:
<xsl:template match="r">
<xsl:if test="string(following-sibling::*[2]/self::*[name(.)='status'])">
<recipient>
<name><xsl:value-of select="."/></name>
<received><xsl:value-of
select="following-sibling::recieved[1]"/></received>
<status><xsl:value-of select="following-sibling::status[1]"/></status>
</recipient>
</xsl:if>
</xsl:template>
David.
--
David McNally
Software Engineer
Moody's Investors Service
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list