thanks a lot Pierre and arigato, Matsuhashi-san
for the answers!!

It's been very helpful.  Yes, I also wish, like many of us, that these needed
changes in XPath and JSTL will be available soon,

Gisella

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:matsuhashi@;quick.co.jp]
Sent: Wednesday, November 13, 2002 6:04 PM
To: Tag Libraries Users List
Subject: Re: namespaces in x:parse



Hi,

In the last Oct - Nov time, I posted an issue to this "Taglib User List",
which is very similar to your problem. The title of my initial post was
"Does JSTL XML taglibs ignore XMLNamespace of input document?"(later I
found this title was incorrect, not forcusing my problem precisely) dated
at 09 Oct 2002.

Shawn Bayern kindly responded to my post which was followed by several
e-mail exchanges between Shawn and me. Unfortunately you can not see them
at the Taglib User List archieve at
http://www.mail-archive.com/taglibs-user@;jakarta.apache.org/ for some
reason (may be due to my mistake). If you require I can send the record to
you.

The simple answer I got from Shawn Bayarn was that, as far as JSTL1.0
specification tells, you can NOT use the namespace prefixes in XPath
expressions in <x:... select="xpath">. If you want to process an input XML
document with explicit Namespaces (in other word, qualified elements), you
need to explicitly use the local-name() function and namespace-uri()
function, or name() function defined by XPath1.0 specification to make your
XPath well-matching against the input document.

The way you can do in JSTL1.0 would be to write something like:

  <x:set var="mediumColor" scope="application"
 select="string($colorsXml//stylesheet[namespace-uri()
="http://www.w3.org/1999/XSL/Transform"]/variable[namespace-uri()
="http://www.w3.org/1999/XSL/Transform and @name='medium']/@select)" />

(sorry, I did not check if this code runs properly for you. I meant to show
you how to use the namespace-url() function to make the XPath valid without
using namespace prefixes ...).

Shawn's "JSTL Action" book has a section where he explained what you can
and cannot do in XPath expression in the JSTL1.0 way. In there you would
find more precise explanation than my (may be inaccurate) note.

------------------------------

When I got to know that I can not use XML Namespace prefixes in XPath
expression in <x:...> tags and therefore the XPath expressions tend to be
very long and hard-to-read/write, I wanted to find out if there is any
possibility for JSTL1.0 specification betterment. So I did a quick hack
(modify taglib implementation to allow namespace prefixes in xpath). I
reached a conclusion that a specification betterment seems to be possible.

At the end of discussion, Shawn mentioned an idea of introducing a new tag
by which you can register combinations of Namespace prefix and URI which to
be reffered from the XPath expressions within <x:... select="xpath"> tags.
Consider that new tag is introduced, your code could look something like:

<c:import var="colors" url="/mwr/colors.xsl"/>
<x:parse xml="${colors}" var="colorsXml"/>
<x:registerNamespace prefix="xsl" uri
="http://www.w3.org/1999/XSL/Transform"; scope="..."/>
          <!-- registerNamespace tag is NOT defined in the JSTL1.0
specification !!! -->
<x:set var="mediumColor" scope="application"
  select="string($colorsXml//xsl:stylesheet/xsl:variable[@name
='medium']/@select)" />
...

This code looks short, much readable, quite in synch with the XSLT way of
using XPath!
Don't you think so?



     MATSUHASHI,kazuaki (FAMILY,given)
     QUICK Corp
     Japan
     [EMAIL PROTECTED]




--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@;jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@;jakarta.apache.org>

Reply via email to