trouble with variables value not available

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
1ded6
Posts: 4

trouble with variables value not available

Thu Apr 13, 2017 7:07 pm

Hello,

Assuming that :

Code: Select all

   <xsl:variable name="eur-uri" select="resolve-uri('prices/eur.xml',base-uri())"/>
   <xsl:variable name="eur-node" select="document($eur-uri)" />

Can someone explain me why this is retrieving some data :

Code: Select all

    <xsl:value-of select="$eur-node//node()[text() = '4.99']/@position" />

and this is not ( i get the message "The variable value is unavailable') :

Code: Select all

    <xsl:variable name="prix-fr" as="xs:string" ><xsl:text>4.99</xsl:text></xsl:variable>
    <xsl:value-of select="$eur-node//node()[text() = $prix-fr]/@position" />

I am working with oxygen 16.1 and saxon 9.5 HE. Any help would be much appreciated. I am really annoyed because when i put my xpath in xwatch, the second option works... :$ tried a lot of things and i can't get it to work with my variable...
Radu
Posts: 5505

Re: trouble with variables value not available

Fri Apr 14, 2017 9:21 am

Hi,

I created a small XML and XSLT to reproduce your situation.
The XML looks like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <a position="abc">4.99</a>
</root>


and the XSLT looks like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">
    <xsl:template match="/">
        <root>
            <xsl:variable name="eur-uri" select="resolve-uri('eur.xml',base-uri())"/>
            <xsl:variable name="eur-node" select="document($eur-uri)" />
           
            <xsl:variable name="prix-fr" as="xs:string" ><xsl:text>4.99</xsl:text></xsl:variable>
            <xsl:value-of select="$eur-node//node()[text() = $prix-fr]/@position" />
        </root>
    </xsl:template>
</xsl:stylesheet>


On my side the transformation works and produces the proper result, it outputs the "abc" position on the element.
So please give me more details about your problem, maybe some screenshots... Does the publishing fail to produce the desired output or does the XSLT debugger sometimes present the wrong value for certain variables?

Officially we no longer give tech support advice or make fixes for for Oxygen 16:

https://www.oxygenxml.com/eol.html#eol_tables

so maybe at some point you could consider upgrading.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
1ded6
Posts: 4

Re: trouble with variables value not available

Fri Apr 14, 2017 10:39 am

Hello Radu,

Thank you so much for the answer.
I have not thought that the debugger could be wrong and did not check the publishing result.
I'll investigate further in this direction and come back to you.

Regards.
1ded6
Posts: 4

Re: trouble with variables value not available

Fri Apr 14, 2017 10:56 am

Ok. It was the debugger... lost a day with that. :evil:
I will definitely consider upgrading with such a great support ! Thank you !
Radu
Posts: 5505

Re: trouble with variables value not available

Fri Apr 14, 2017 11:07 am

Hi,

Usually the debugger reports things like The variable value is unavailable because the Saxon 9 XSLT processor may choose to postpone evaluating a variable, for example it may not evaluate the variable at all if it is not used at all or it may evaluate the variable only when it reaches the place where it's used.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 2 guests