Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSl Var out of scope

From: "Joe Fawcett" <joefawcett@---------.------>
To: 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





transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent