This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re:
- To: "Kevin 'esq' Byrne" <kbyrne7 at yahoo dot com>
- Subject: Re:
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Fri, 3 Nov 2000 14:38:35 -0400 (EST)
- Cc: xsl-list at mulberrytech dot com
- Reply-To: xsl-list at mulberrytech dot com
Kevin,
Just to turn around your message:
>I presume I use:
> <xsl:template match="fundgraph">
><xsl:with-param name="fundgraph">
><xsl:value-of select="...">
></xsl:param>
></xsl:template>
I don't think so. xsl:with-param is used to pass parameters into
templates. Perhaps you meant xsl:param (to match the end tag you've got in
that template), but neither of these instructions will do anything about
adding things to your output, which I think is what you want.
>I need the following xml to be converted to
>accommodate a graph applet. Hence, I need parameter
>tags for the fundgraph and fundvalue elements.
>
><!ELEMENT fundgraph (fundvalue*)>
> <!ATTLIST fundgraph startDate CDATA #REQUIRED>
> <!ATTLIST fundgraph endDate CDATA #REQUIRED>
> <!ATTLIST fundgraph fundName CDATA #REQUIRED>
>
> <!ELEMENT fundvalue EMPTY>
> <!ATTLIST fundvalue date CDATA #REQUIRED>
> <!ATTLIST fundvalue value CDATA #REQUIRED>
> <!ATTLIST fundvalue ordinal CDATA #REQUIRED>
From what you've described, your input will look something like:
<fundgraph startDate="99-11-03" endDate="00-11-03" fundName="Technical">
<fundvalue date="99-11-03" value="0.58" ordinal="0" />
<fundvalue date="99-12-03" value="0.75" ordinal="0" />
...
</fundgraph>
and you want output might (complete guess here) look something like:
<object ...>
<param name="startDate" value="99-11-03" />
<param name="endDate" value="00-11-03" />
<param name="title" value="Technical" />
<param name="99-11-03" value="0.58" />
<param name="99-12-03" value="0.75" />
...
</object>
The param elements that you're creating in the output are not the same as
the xsl:param elements that are used within XSLT to pass values into the
stylesheet or into templates. The param elements in your output are in the
HTML namespace, whereas the xsl:param elements in the stylesheet are in the
XSLT namespace.
Just to start you off with the above example, you create elements within
your output either by using the xsl:element instruction:
<xsl:element name="object">
...
</xsl:element>
or by literally putting the element in the result tree:
<object>
...
</object>
So, to create the above, you could have a stylesheet that looks like:
<!-- set the output method to HTML -->
<xsl:output method="html" indent="yes" />
<xsl:template match="fundgraph">
<!-- create an object element -->
<object ...>
<!-- create the param elements from the fundgraph attribute values -->
<param name="startDate" value="{@startDate}" />
<param name="endDate" value="{@endDate}" />
<param name="title" value="{@fundName}" />
<!-- iterate over each of the fundvalue elements,
adding a param element for each -->
<xsl:for-each select="fundvalue">
<param name="{@date}" value="{@value}" />
</xsl:for-each>
</object>
</xsl:template>
I hope that gets you started. If not, feel free to post more details,
namely a sample bit of source XML and the output that you want to have
created from it.
Cheers,
Jeni
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list