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

RE: rendering marginal XML

Subject: RE: rendering marginal XML
From: "Chris Bayes" <chris@xxxxxxxxxxx>
Date: Fri, 26 Oct 2001 20:04:25 +0100
you2 video success
Jay,
Well say what you want up front. Don't beat about the bush!

Mike,
I don't think that will work.
I think there might be a way to do it with keys but using this input

<?xml version="1.0" ?>
<msgs>
<msgSent>
	<time>time sent</time>
	<origin>me@xxxxxxxx</origin>
	<r>you1@xxxxxxxxx</r>
	<recieved>1time recieved</recieved>
	<status>Any error messages, etc</status>
	<r>you2@xxxxxxxxx</r>
	<recieved>2time recieved</recieved>
	<r>you3@xxxxxxxxx</r>
	<recieved>3time recieved</recieved>
	<r>you4@xxxxxxxxx</r>
	<recieved>4time recieved</recieved>
	<status>Any error messages, etc</status>
	<r>you5@xxxxxxxxx</r>
	<recieved>5time recieved</recieved>
	
</msgSent>
</msgs>

And this stylesheet

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="/msgs">	
		<html>
			<head></head>
			<body>
				<xsl:apply-templates select="msgSent" />
			</body>
		</html>
	</xsl:template>
	<xsl:template match="msgSent">
		ERROR: <br />
		<xsl:apply-templates select="status" />
		SUCCESS: <br />
		<xsl:apply-templates select="r" />
	</xsl:template>
	<xsl:template match="status">
		<xsl:value-of select="preceding-sibling::r[1]" /> ERROR:
<xsl:value-of select="." /> AT: <xsl:value-of
select="preceding-sibling::recieved[1]" /><br />
	</xsl:template>
	
	<xsl:template match="r">
		<xsl:variable name="ps"><xsl:call-template name="fs"
/></xsl:variable>
		<xsl:variable name="pr"><xsl:call-template name="fr"
/></xsl:variable>
		<xsl:if test="$pr &lt; $ps or $pr = ''">
			<xsl:value-of select="." /> SUCCESS AT:
<xsl:value-of select="following-sibling::recieved" /><br />
		</xsl:if>
	</xsl:template>
	<xsl:template name="fr">
		<xsl:for-each select="following-sibling::r[1]">
			<xsl:value-of
select="count(preceding-sibling::*)" />
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="fs">
		<xsl:for-each select="following-sibling::status[1]">
			<xsl:value-of
select="count(preceding-sibling::*)" />
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>

You get this output

<body>
ERROR: <br>
you1@xxxxxxxxx ERROR: Any error messages, etc AT: 1time recieved<br>
you4@xxxxxxxxx ERROR: Any error messages, etc AT: 4time recieved<br>
SUCCESS: <br>
you2@xxxxxxxxx SUCCESS AT: 2time recieved<br>
you3@xxxxxxxxx SUCCESS AT: 3time recieved<br>
you5@xxxxxxxxx SUCCESS AT: 5time recieved<br>
</body>

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Michael Kay
> Sent: 26 October 2001 19:02
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  rendering marginal XML
> 
> 
> >
> > <msgSent>
> > 	<time>time sent</time>
> > 	<origin>me@xxxxxxxx</origin>
> > 	<r>you@xxxxxxxxx</r>
> > 	<recieved>time recieved</recieved>
> > 	<status>Any error messages, etc</status>
> > 	<r>you2@xxxxxxxxx</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>
> 
> <xsl:template match="recieved|status"/>
> 
> Mike Kay
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


 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.