 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 5th, 2007, 06:20 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
multiple param values in XSLT1.0
Hallo all,
because I am pretty new with this XSLT 1.0 specifications (I was programming with 2.0) I am having a question.
I have a parameter which I want to reference with-param. Here is my point is that this param should have more than one values. So what ist the notation for it?
for example
for the values 1,2,3
<xsl:call-template = "foo">
<xsl:with-param name = "bar" select = "1,2,3"/>?? (It should have either 1, 2 or 3)
</xsl:call-template>
can anyone help me please?
Your attitude determines your altitude
__________________
Your attitude determines your altitude
|
|

February 5th, 2007, 06:46 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
The XPath 1.0 type system has no data type to represent a collection of integers. You can pass a string such as "1,2,3" but you will then have to parse it yourself at the other end. A better approach might be to construct an XML tree containing
<e><v>1</v><v>2</v><v>3</v></e>
however, to pick out the values from that you'll still need the xx:node-set() extension function.
Programming in XSLT 1.0 is very frustrating once you have become accustomed to the extra power of 2.0.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

February 5th, 2007, 07:04 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Michael. I have another question.
I have written it like
<xsl:call-template = "foo">
<xsl:with-param name = "bar" select = "contains('#102#203#204#', concat('#', messagedateformat, '#'))""/>
</xsl:call-template>
So I have another parameter which checks this value like
<xsl:with-param name ="check" select ="203"/>
I have written this when statement in foo template:
<xsl:when test="not(bar=check)">
<xsl:element name="error">
<xsl:attribute name="type">element</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="$element"/>
</xsl:attribute>
<xsl:attribute name="message">Illegal value. It must be <xsl:value-of select="$bar"/></xsl:attribute>
</xsl:element>
</xsl:when>
So 204 is in this container that is why it is giving me now this error message:
<error type="element" name="messagedateformat" message="Illegal value. It must be true" value="204" />
trues is I think the return of this bar param name. So how can I solve this problem? I should not have received this error message because 204 is included in bar parameter.
Your attitude determines your altitude
|
|

February 5th, 2007, 07:15 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok I solved my problem I had to take them as variables that is why the $ sign has solved my problem. I hate this XSLT 1.0.
Your attitude determines your altitude
|
|

February 5th, 2007, 07:37 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Firstly, your condition should be ($bar=$check) because these are the names of variables.
But $bar is a boolean value (true or false) while $check is an integer, so it doesn't make sense to compare them.
Finally, I can't see what code is outputting value="204" so I have no idea if this is actually the value of $check.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

February 5th, 2007, 07:43 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
> I hate this XSLT 1.0.
Would I be right in guessing that XSLT 1.0 is your second programming language? This kind of reaction to a second language is very common: people grow up imagining that the only way to write "not equals" is "<>", and get very upset when they find in their second language that it is written "~=" or "!=". Once you're on your fifth or sixth language, you start to realise that these kind of differences are arbitrary and superficial, and you just have to put up with them.
The differences are usually there for a reason, and it helps to understand the reason: in the case of XSLT, an undecorated name is a reference to a child element, so references to variables need a syntactic marker to distinguish them. The "$" sign was chosen because there are many other languages that already used "$" as a syntactic marker for variables.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
 |