Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT2.0 temporary nodeset as parameter

Reply
Thread Tools

XSLT2.0 temporary nodeset as parameter

 
 
RolfK
Guest
Posts: n/a
 
      12-17-2007
Dear ALL,

I'm new to XSLT2.0 and want to switch from XSLT1.0 to make my scripts
smaller.
My understanding of XSLT2.0 is that I can appply XPATH(2.0) on a
fragment without calling a specific node-set function. I'm using saxon
8.0.
The example has three parts the xslt, a xml called with saxon and a
xml loaded by document function. I have to process over the two xml
node sets.

Running the xslt gives me the follwoing error message:

Error at value-of on line 29 of file:/proj/URANUS/_work_kemperr/_V1.0/
_xml/TESTCASE/Stimulus20.xslt:
Required type of first operand of '/' is node(); supplied value is
xs:string
Transformation failed: Run-time errors were reported

The question is why the parameter value is treated as string ?

In case I comment out the critical line (<xsl:value-of
select="$pParams[1]/@Value" />) I get the expeted
################ result ##################
Calling Sequence LEVEL1
Vector 2BIT
Calling Sequence LEVEL2
Nested Vector 1BIT
Nested Vector 2BIT
Vector 3BIT
duecs37: saxon StimulusTest1.xml Stimulus20.xslt
Vector 1
Calling Sequence LEVEL1
Vector 2BIT
Calling Sequence LEVEL2
Nested Vector 1BIT
Nested Vector 2BIT
Vector 3BIT

################### xslt ##############################
<xsl:stylesheet version="2.0" xmlnssl="http://www.w3.org/1999/XSL/
Transform">
<!-- saxon call: saxon StimulusTest1.xml Stimulus20.xslt -->
<!-- THIS IS A XSLT 2.0 SCRIPT -->
<xslutput method="text" version="1.0" encoding="UTF-8" indent="no"/
>

<xsl:variable name="gfDEF" select="document('StimulusDef1.xml')/
STIMULUSDEF"/>
<xsl:variable name="cNewLine" select="'&#x0a;'"/>
<!-- we call the xslt on the StimulusTest.xml -->
<xsl:template match="/">
<xsl:apply-templates select="STIMULUS/TEST/CREATE"/>
</xsl:template>

<xsl:template match="CREATE">
<xslaram name="pParams"/>
<xsl:variable name="vSeqName" select="@Name"/>
<xsl:value-of select="@Comment"/>
<xsl:apply-templates select="BIT">
<xsl:with-param name="pParams" select="$pParams"/>
</xsl:apply-templates>
<xsl:value-of select="$cNewLine"/>
<xsl:if test="@VectorType='Sequence'">
<xsl:apply-templates select="$gfDEF/SEQS/SEQ[@Name=$vSeqName]/
CREATE">
<xsl:with-param name="pParams" select="PARAM"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template match="BIT">
<xslaram name="pParams"/>
<xsl:text>BIT</xsl:text>
<xsl:value-of select="$pParams[1]/@Value" />
</xsl:template>

</xsl:stylesheet>
################## xml called wit saxon ####################
<?xml version="1.0" encoding="UTF-8"?>
<STIMULUS DefPath="StimulusDef.xml">
<TEST Name="MyTest" >
<CREATE VectorType="Vector" Comment="Vector 1"/>
<CREATE VectorType="Sequence" Name="LEVEL1" Comment="Calling
Sequence LEVEL1">
<PARAM Name="Addr" Value="'ADDR1'"/>
<PARAM Name="Write" Value="'DATA1'"/>
</CREATE>
<CREATE VectorType="Vector" Split="CSISplit" Comment="Vector 2">
<BIT Name="BIT1" Value="2"/>
</CREATE>
<CREATE VectorType="Sequence" Name="LEVEL2" Comment="Calling
Sequence LEVEL2">
<PARAM Name="Addr" Value="'ADDR2'"/>
<PARAM Name="Write" Value="'DATA2'"/>
</CREATE>
<CREATE VectorType="Vector" Comment="Vector 3">
<BIT Name="BIT1" Value="3"/>
</CREATE>
</TEST>
</STIMULUS>
######################## xml called by document function ############
<?xml version="1.0" encoding="UTF-8"?>
<STIMULUSDEF>
<SEQS>
<SEQ Name="LEVEL2" Comment="Level 2">
<CREATE VectorType="Vector" Comment="Nested Vector 1" >
<BIT Name="BIT1" Value="2.1"/>
</CREATE>
<CREATE VectorType="Vector" Comment="Nested Vector 2">
<BIT Name="BIT1" Value="2.2"/>
</CREATE>
</SEQ>
<SEQ Name="LEVEL1A" Comment="Level 1A">
<CREATE VectorType="Vector" Comment="LEVEL1A Vector 1" >
<BIT Name="BIT1" Value="1.1"/>
</CREATE>
<CREATE VectorType="Vector" Comment="LEVEL1A Vector 2" >
<BIT Name="BIT1" Value="1.2"/>
</CREATE>
</SEQ>
<SEQ Name="LEVEL1B" Comment="Level 1B">
<CREATE VectorType="Vector" Comment="LEVEL1B Vector 1" >
<BIT Name="BIT1" Value="10.1"/>
</CREATE>
<CREATE VectorType="Sequence" Name="LEVEL2" Comment="Call nested
sequence " >
<PARAM Name="Addr" Value="'ADDR3'"/>
<PARAM Name="Write" Value="'DATA3'"/>
</CREATE>
<CREATE VectorType="Vector" Comment="LEVEL1BVector 1" >
<BIT Name="BIT1" Value="10.2"/>
</CREATE>
</SEQ>
</SEQS>
</STIMULUSDEF>
############# END ##########################

 
Reply With Quote
 
 
 
 
Pavel Lepin
Guest
Posts: n/a
 
      12-17-2007

RolfK <(E-Mail Removed)> wrote in
<(E-Mail Removed)>:
> Running the xslt gives me the follwoing error message:
>
> Error at value-of on line 29 of
> file:/proj/URANUS/_work_kemperr/_V1.0/
> _xml/TESTCASE/Stimulus20.xslt:
> Required type of first operand of '/' is node();
> supplied value is
> xs:string
> Transformation failed: Run-time errors were reported
>
> The question is why the parameter value is treated as
> string ?
>
> ################### xslt ##############################
> <xsl:stylesheet version="2.0"
> xmlnssl="http://www.w3.org/1999/XSL/ Transform">
> <!-- saxon call: saxon StimulusTest1.xml Stimulus20.xslt
> --> <!-- THIS IS A XSLT 2.0 SCRIPT -->
> <xslutput method="text" version="1.0" encoding="UTF-8"
> indent="no"/
>>

> <xsl:variable name="gfDEF"
> select="document('StimulusDef1.xml')/ STIMULUSDEF"/>
> <xsl:variable name="cNewLine" select="'&#x0a;'"/>
> <!-- we call the xslt on the StimulusTest.xml -->
> <xsl:template match="/">
> <xsl:apply-templates select="STIMULUS/TEST/CREATE"/>


Invoked without xsl:with-param...

> </xsl:template>
>
> <xsl:template match="CREATE">
> <xslaram name="pParams"/>


....therefore this is uninitialized. See 9.2 in XSLT2, which
answers the question you posed above.

> <xsl:variable name="vSeqName" select="@Name"/>
> <xsl:value-of select="@Comment"/>
> <xsl:apply-templates select="BIT">
> <xsl:with-param name="pParams" select="$pParams"/>


And now you invoke the template application, passing
zero-length string as pParams parameter.

> </xsl:apply-templates>
> <xsl:value-of select="$cNewLine"/>
> <xsl:if test="@VectorType='Sequence'">
> <xsl:apply-templates
> select="$gfDEF/SEQS/SEQ[@Name=$vSeqName]/ CREATE">
> <xsl:with-param name="pParams" select="PARAM"/>
> </xsl:apply-templates>
> </xsl:if>
> </xsl:template>
> <xsl:template match="BIT">
> <xslaram name="pParams"/>
> <xsl:text>BIT</xsl:text>
> <xsl:value-of select="$pParams[1]/@Value" />


And, naturally, it all breaks here, because, as Saxon told
you, / wants a nodeset as the first operand, and you're
passing a string. What else did you expect?

> </xsl:template>
>
> </xsl:stylesheet>


--
....also, I submit that we all must honourably commit seppuku
right now rather than serve the Dark Side by producing the
HTML 5 spec.
 
Reply With Quote
 
 
 
 
RolfK
Guest
Posts: n/a
 
      12-18-2007
On 17 Dez., 08:55, Pavel Lepin <(E-Mail Removed)> wrote:
> RolfK <(E-Mail Removed)> wrote in
> <(E-Mail Removed)>:
>
>
>
>
>
> > Running the xslt gives me the follwoing error message:

>
> > Error at value-of on line 29 of
> > file:/proj/URANUS/_work_kemperr/_V1.0/
> > _xml/TESTCASE/Stimulus20.xslt:
> > Required type of first operand of '/' is node();
> > supplied value is
> > xs:string
> > Transformation failed: Run-time errors were reported

>
> > The question is why the parameter value is treated as
> > string ?

>
> > ################### xslt ##############################
> > <xsl:stylesheet version="2.0"
> > xmlnssl="http://www.w3.org/1999/XSL/Transform">
> > <!-- saxon call: saxon StimulusTest1.xml Stimulus20.xslt
> > --> <!-- THIS IS A XSLT 2.0 SCRIPT -->
> > <xslutput method="text" version="1.0" encoding="UTF-8"
> > indent="no"/

>
> > <xsl:variable name="gfDEF"
> > select="document('StimulusDef1.xml')/ STIMULUSDEF"/>
> > <xsl:variable name="cNewLine" select="'&#x0a;'"/>
> > <!-- we call the xslt on the StimulusTest.xml -->
> > <xsl:template match="/">
> > <xsl:apply-templates select="STIMULUS/TEST/CREATE"/>

>
> Invoked without xsl:with-param...
>
> > </xsl:template>

>
> > <xsl:template match="CREATE">
> > <xslaram name="pParams"/>

>
> ...therefore this is uninitialized. See 9.2 in XSLT2, which
> answers the question you posed above.
>
> > <xsl:variable name="vSeqName" select="@Name"/>
> > <xsl:value-of select="@Comment"/>
> > <xsl:apply-templates select="BIT">
> > <xsl:with-param name="pParams" select="$pParams"/>

>
> And now you invoke the template application, passing
> zero-length string as pParams parameter.
>
> > </xsl:apply-templates>
> > <xsl:value-of select="$cNewLine"/>
> > <xsl:if test="@VectorType='Sequence'">
> > <xsl:apply-templates
> > select="$gfDEF/SEQS/SEQ[@Name=$vSeqName]/ CREATE">
> > <xsl:with-param name="pParams" select="PARAM"/>
> > </xsl:apply-templates>
> > </xsl:if>
> > </xsl:template>
> > <xsl:template match="BIT">
> > <xslaram name="pParams"/>
> > <xsl:text>BIT</xsl:text>
> > <xsl:value-of select="$pParams[1]/@Value" />

>
> And, naturally, it all breaks here, because, as Saxon told
> you, / wants a nodeset as the first operand, and you're
> passing a string. What else did you expect?
>
> > </xsl:template>

>
> > </xsl:stylesheet>

>
> --
> ...also, I submit that we all must honourably commit seppuku
> right now rather than serve the Dark Side by producing the
> HTML 5 spec.- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -


Pavel , thanks a lot,
I think it gets clear now.
Saxon seems to be quite strict which is good in my understanding.
Rolf
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
anonymous array of strings // ("taking address of temporary"- how long is temporary valid?) anon.asdf@gmail.com C++ 7 02-12-2008 10:58 AM
Nodeset Difference AKA Nodeset Reduction Bryan Galvin XML 2 09-29-2004 12:09 PM
Please clarify how null nodeset result processes? Kathy Burke ASP .Net 5 08-26-2003 07:03 PM
PRETTY PLEASE...need answer to why "this method should result in NodeSet" error KathyB ASP .Net 0 07-25-2003 04:59 AM
Intersecting Nodeset Xeon XML 1 07-21-2003 09:10 PM



Advertisments