xsl-list
[Top] [All Lists]

Re: variable holding a xml document created by xslt

2004-04-11 03:13:47
David,

Can I use something like this to build the list-

<xsl:template name="build-list">
 <xsl:param name="list"/>
 <xsl:choose>
  <xsl:when test="not end of data...">
    <xsl:variable name="item">
     <xsl:element name="label">
      <xsl:attribute name="x1">from the input xml</xsl:attribute>
      <xsl:attribute name="x2">from the input xml</xsl:attribute>
     </xsl:element>
    </xsl:variable>
   <xsl:call-template name="build-list">
    <xsl:with-param name="list" select="$list+$item"
   </xsl:call-template>
  </xsl:when>
 <xsl:otherwise>
  <value-of select=$list/>
 </xsl:otherwise>
 </xsl:choose>
</xsl:template>

I just want to verfify the syntax of adding elements.

Thanks,

-RVG





----- Original Message ----- 
From: "M. David Peterson" <m(_dot_)david(_at_)mdptws(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Sunday, April 11, 2004 7:09 PM
Subject: RE: [xsl] variable holding a xml document created by xslt


Hey Robert,

In fact I believe I remember our conversation from last year.  Im glad
to see that the lookup table has been of some help to you.  You are
correct in how you would access the value of the variable. But in this
particular case you are going to need to use the node-set function of
msxsl to give you what you need.  To do this you will need to declare
the msxsl namespace as a part of your stylesheet decleration like so...

<xsl:stylesheet version = "1.0" 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:msxsl="urn:schemas-microsoft-com:xslt"
   exclude-result-prefixes = "msxsl">

Next, you will need to create a variable that contains the dynamic
values you want.

<xsl:variable name="getLookupValuesforRect">
<xsl:element name="label">
<xsl:attribute name="x1">100</xsl:attribute>
   <xsl:attribute name="x2">110</xsl:attribute>
</xsl:element>
</xsl:variable>

Finally, create another variable that you will call the node-set
function from within the select attribute.  You will then you the method
you describe to access its content.

<xsl:variable name="get-rect"
select="msxsl:node-set($getLookupValuesforRect)/>

If the size of the xml tree was reasonable you could just use one
variable like so:

<xsl:variable name="get-rect" select="msxsl:node-set('<label x1="100"
x2="110">')/>

But its easy to see how this method could become unmanageable fairly
quickly...

Either way using "$get-rect/label/@x1" will get you the value of
attribute x1.

Hope this helps!

Best regards,

<M:D/>

-----Original Message-----
From: Robert Van Gemert 
[mailto:rcvangemert(_at_)optushome(_dot_)com(_dot_)au] 
Sent: Sunday, April 11, 2004 2:47 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] variable holding a xml document created by xslt

Thanks David,

Confused? yep!

You showed me the lookup idea last year and I use it now for constants
but
in this case the lookup list will change depending on what lables are in
view, so the list needs to be created dynamically.

I am using msxml4,  I think you are suggesting that if I create a
template
that returns a xml fragment

eg.

<template name="get-rect"
 <xsl:value-of select>
   <lable>
    <xsl:attribute name="x1">100</xsl:attribute>
    <xsl:attribute name="x2">110</xsl:attribute>
  <lable>
 </xsl:value-of select>
</template>

I can access this fragment using

<xsl:variable name="lable-rect">
 <xsl:call-template name="get-rect"/>
<xsl:variable>

$lable-rect/@x1

-RVG






--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--