This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: What stylesheet might I use to parse the xml..
- To: xsl-list at mulberrytech dot com
- Subject: Re: What stylesheet might I use to parse the xml..
- From: Matthew Cordes <mcorde61 at maine dot edu>
- Date: Mon, 10 Apr 2000 00:03:43 -0400
- References: <20000409224014.A523@dt040n7f.maine.rr.com>
- Reply-To: xsl-list at mulberrytech dot com
Please ignore this message. Steve Muench <smuench@us.oracle.com>
provided a suitable explaination to my previous post. Sorry for wasting
your time.
-matt
On Sun, Apr 09, 2000 at 10:40:14PM -0400, Matthew Cordes wrote:
> Hello, I have some xml that I want to reorder, but leave in xml format
> via an xsl. What I have right now isn't working, please help.
>
>
> Starting xml:
>
> <resultset>
> <result>
> <name> Art </name>
> <age> 22 </age>
> <course> mes-399 </course>
> </result>
> <result>
> <name> Pat </name>
> <age> 22 </age>
> <course> cos-399 </course>
> </result>
> <result>
> <name> Stan </name>
> <age> 45 </age>
> <course> mes-399 </course>
> </result>
> <result>
> <name> Jimmy </name>
> <age> 23 </age>
> <course> cos-399 </course>
> </result>
> </resultset>
>
>
> Here is the stylesheet I used,
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:template match="/">
> <courses>
> <xsl:apply-templates select="/resultset/result"/>
> </courses>
> </xsl:template>
>
> <xsl:template match="result">
> <course>
> <xsl:attribute name="title">
> <xsl:value-of select="course"/>
> </xsl:attribute>
> <student>
> <name> <xsl:value-of select="name"/> </name>
> <age> <xsl:value-of select="age"/> </age>
> </student>
> </course>
> </xsl:template>
> </xsl:stylesheet>
>
>
> together these output:
>
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <courses>
> <course title="mes-399">
> <student>
> <name> Art </name>
> <age>22</age>
> </student>
> </course>
> <course title="cos-399">
> <student>
> <name> Pat </name>
> <age>22</age>
> </student>
> </course>
> <course title="mes-399">
> <student>
> <name> Stan </name>
> <age>45</age>
> </student>
> </course>
> <course title="cos-399">
> <student>
> <name> Jimmy </name>
> <age>23</age>
> </student>
> </course>
> </courses>
>
>
> when I really wanted this output:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <courses>
> <course title="mes-399">
> <student>
> <name> Art </name>
> <age>22</age>
> </student>
> <student>
> <name> Stan </name>
> <age>45</age>
> </student>
> </course>
> <course title="cos-399">
> <student>
> <name> Pat </name>
> <age>22</age>
> </student>
> <student>
> <name> Jimmy </name>
> <age>23</age>
> </student>
> </course>
> </courses>
>
> Notice how the desired xml above is grouped by course, while the real
> output is not. Can anyone help me do it this way?
>
> Perhaps also, some kind of xsl that would allow me to compress nodes with
> the same name would also work (e.g., above, <course title="cos-399">
> appears twice, but I really only want it once ).
>
> Thanks for reading this,
>
> -matt
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list