Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 28th, 2006, 05:55 PM
kforski@gmail.com
Guest
 
Posts: n/a
Default How to determine if param is defined in XSL

Hello

I wonder how can I find out if the param given to the xsl is defined
without error during compilation.

Actually I have such code (a part of it)

<xsl:if test="$showWarnings='true']">
<p><xsl:apply-templates select="$list" mode="errors"/></p>
</xsl:if>

But the $showWatnings can be undefined so I got error: "variable
"showWarnings" not defined". Some external (java) threads transform a
xml file with many data using the same xsl. Some of them define param
<xsl:param name="showWarnings">true</xsl:parambut others not and
those others shouldn't even know about such param.

Any idea?? Please?

  #2  
Old July 29th, 2006, 02:35 AM
Joe Kesselman
Guest
 
Posts: n/a
Default Re: How to determine if param is defined in XSL

When you declare the parameter, set up a default value that you can
recognize as not having been passed in.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
  #3  
Old July 29th, 2006, 02:45 AM
Dimitre Novatchev
Guest
 
Posts: n/a
Default Re: How to determine if param is defined in XSL


<kforski@gmail.comwrote in message
news:1154105778.271377.140370@75g2000cwc.googlegro ups.com...
Quote:
Hello
>
I wonder how can I find out if the param given to the xsl is defined
without error during compilation.
>
Actually I have such code (a part of it)
>
<xsl:if test="$showWarnings='true']">
<p><xsl:apply-templates select="$list" mode="errors"/></p>
</xsl:if>
>
But the $showWatnings can be undefined so I got error: "variable
"showWarnings" not defined". Some external (java) threads transform a
xml file with many data using the same xsl. Some of them define param
<xsl:param name="showWarnings">true</xsl:parambut others not and
those others shouldn't even know about such param.
>
Any idea?? Please?
>
If the xsl:param is a global one, use this XPath expression to determine its
presence in the stylesheet:

document('')/*/xls:param[@name = 'showWarnings']

The above may not be usable if the stylesheet is dynamically generated (not
loaded from a file or URL).

Cheers,
Dimitre Novatchev


  #4  
Old July 31st, 2006, 09:25 AM
kforski@gmail.com
Guest
 
Posts: n/a
Default Re: How to determine if param is defined in XSL

But like I said there can be situation that this param won't be even
declared!!
Joe Kesselman wrote:
Quote:
When you declare the parameter, set up a default value that you can
recognize as not having been passed in.
>
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
  #5  
Old July 31st, 2006, 09:25 AM
kforski@gmail.com
Guest
 
Posts: n/a
Default Re: How to determine if param is defined in XSL

Could you please write a simple example how to use this expression in
such "if" clause?

Dimitre Novatchev wrote:
Quote:
<kforski@gmail.comwrote in message
news:1154105778.271377.140370@75g2000cwc.googlegro ups.com...
Quote:
Hello

I wonder how can I find out if the param given to the xsl is defined
without error during compilation.

Actually I have such code (a part of it)

<xsl:if test="$showWarnings='true']">
<p><xsl:apply-templates select="$list" mode="errors"/></p>
</xsl:if>

But the $showWatnings can be undefined so I got error: "variable
"showWarnings" not defined". Some external (java) threads transform a
xml file with many data using the same xsl. Some of them define param
<xsl:param name="showWarnings">true</xsl:parambut others not and
those others shouldn't even know about such param.

Any idea?? Please?
>
If the xsl:param is a global one, use this XPath expression to determine its
presence in the stylesheet:
>
document('')/*/xls:param[@name = 'showWarnings']
>
The above may not be usable if the stylesheet is dynamically generated (not
loaded from a file or URL).
>
Cheers,
Dimitre Novatchev
  #6  
Old July 31st, 2006, 01:45 PM
Dimitre Novatchev
Guest
 
Posts: n/a
Default Re: How to determine if param is defined in XSL


<kforski@gmail.comwrote in message
news:1154334801.849938.106600@i3g2000cwc.googlegro ups.com...
Quote:
Could you please write a simple example how to use this expression in
such "if" clause?
That's pretty basic XSLT:

<xsl:if test="document('')/*/xls:param[@name = 'showWarnings']">

<!-- The param is defined: Do whatever really needs to be done here -->

</xsl:if>


Quote:
>
Dimitre Novatchev wrote:
Quote:
><kforski@gmail.comwrote in message
>news:1154105778.271377.140370@75g2000cwc.googlegr oups.com...
Quote:
Hello
>
I wonder how can I find out if the param given to the xsl is defined
without error during compilation.
>
Actually I have such code (a part of it)
>
<xsl:if test="$showWarnings='true']">
<p><xsl:apply-templates select="$list" mode="errors"/></p>
</xsl:if>
>
But the $showWatnings can be undefined so I got error: "variable
"showWarnings" not defined". Some external (java) threads transform a
xml file with many data using the same xsl. Some of them define param
<xsl:param name="showWarnings">true</xsl:parambut others not and
those others shouldn't even know about such param.
>
Any idea?? Please?
>
>>
>If the xsl:param is a global one, use this XPath expression to determine
>its
>presence in the stylesheet:
>>
> document('')/*/xls:param[@name = 'showWarnings']
>>
>The above may not be usable if the stylesheet is dynamically generated
>(not
>loaded from a file or URL).
>>
>Cheers,
>Dimitre Novatchev
>

  #7  
Old July 31st, 2006, 02:05 PM
Johannes Koch
Guest
 
Posts: n/a
Default Re: How to determine if param is defined in XSL

Dimitre Novatchev schrieb:
Quote:
<xsl:if test="document('')/*/xls:param[@name = 'showWarnings']">
Unless you map the prefix 'xls' to the XSLT namespace, you should write
'xsl:param'.
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
  #8  
Old July 31st, 2006, 02:35 PM
Dimitre Novatchev
Guest
 
Posts: n/a
Default Re: How to determine if param is defined in XSL


"Johannes Koch" <koch@w3development.dewrote in message
news:44ce0052$0$17941$892e7fe2@authen.yellow.readf reenews.net...
Quote:
Dimitre Novatchev schrieb:
Quote:
><xsl:if test="document('')/*/xls:param[@name = 'showWarnings']">
>
Unless you map the prefix 'xls' to the XSLT namespace, you should write
'xsl:param'.

Oops... Thanks -- I only now see it's xls and not xsl

I think the OP made a typo, which I didn't notice. Of course, it must be:

<xsl:if test="document('')/*/xsl:param[@name = 'showWarnings']">


Also, the above implies that the "xsl" prefix is bound the usual way :o)

Cheers,
Dimitre Novatchev


 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles