[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: variable holding a xml document created by xslt
As far as adding elements your spot on. Two things you will want to fix with this are... <xsl:with-param name="list" select="$list | $item"> <xsl:value-of select="$list"/> Im assuming that your test attribute value for xsl:when is only place holding logic? Beyond that it looks pretty good... Let me know if you have any further troubles... <M:D/> -----Original Message----- From: Robert Van Gemert [mailto:rcvangemert@xxxxxxxxxxxxxxxx] Sent: Sunday, April 11, 2004 4:14 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: variable holding a xml document created by xslt 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.david@xxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Sunday, April 11, 2004 7:09 PM Subject: RE: 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@xxxxxxxxxxxxxxxx] > Sent: Sunday, April 11, 2004 2:47 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|