R
RolfK
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" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<!-- saxon call: saxon StimulusTest1.xml Stimulus20.xslt -->
<xsl:variable name="gfDEF" select="document('StimulusDef1.xml')/
STIMULUSDEF"/>
<xsl:variable name="cNewLine" select="'
'"/>
<!-- 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 ##########################
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" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<!-- saxon call: saxon StimulusTest1.xml Stimulus20.xslt -->
<xsl:variable name="gfDEF" select="document('StimulusDef1.xml')/
STIMULUSDEF"/>
<xsl:variable name="cNewLine" select="'
'"/>
<!-- 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 ##########################