Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - XSl Var out of scope >Thread Next - Re: XSl Var out of scope Re: XSl Var out of scopeTo: NULL Date: 4/4/2006 6:36:00 PM "aidy" <aidy.rutter@g...> wrote in message news:1144165671.513977.208050@u...... > Hi, > > This is a snippet of the XML I am dealing with, > > <LOG_MESSAGE type="START DATATABLE" date="03-04-2006" time="16:45:20" > > > <MESSAGE_TEXT><![CDATA[\\gbahes75\Projects\AddressService\Datapool\GetTestID.sdd]]></MESSAGE_TEXT> > </LOG_MESSAGE> > > There is a number of <LOG_MESSAGE> elements > > My aim in the xsl in pseudo code is; > > IF THE <LOG_MESSAGE> ATTRIBUTE TYPE = "START DATATABLE" THEN > GET THE <MESSAGE_TEXT> VALUE > END IF > > This is my XSL > > <xsl:for-each select = "LOG_MESSAGE"> > <xsl:if test="LOG_MESSAGE[type='START DATATABLE']"> > <xsl:variable name="host2" select="MESSAGE_TEXT"/> > <BR> > xsl:value-of select="substring-after($host2,'\')"/> > </BR> > </xsl:if> > </xsl:for-each> > > note: (I actually want the last field [GetTestID.sdd] of the > <MESSAGE_TEXT> but that is a different problem) > > I am using XSLDebugger, but when I attempt to run the XSL I get the > error: > > 'A reference to variable 'host2' cannot be resolved. The variable or > parameter > may not be defined, or it may not be in scope' > > And I am not sure why. > > Cheers > > Aidy > Your XSLT is abit odd, you need @ before an attribute, you could just do: <xsl:for-each select = "LOG_MESSAGE[@type = 'START DATATABLE'"> <br> <xsl:value-of select="substring-after(MESSAGE_TEXT, '\')"/> </br> </xsl:for-each> Not sure why the variable was out of scope though. If you actually want the last field in XSLT 1.0 you probably need to recursively process the value, applying substring-after whilst there is still a \ in the string. -- Joe Fawcett - XML MVP https://mvp.support.microsoft.com/profile=8AA9D5F5-E1C2-44C7-BCE8-8741D22D17A5 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
