You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Karen Schuchardt <kl...@pnl.gov> on 2000/03/10 00:05:13 UTC
problem selecting non-child elements when using name spaces
Hi,
I am trying to convert my .xsl file to make use of a name space. I was
able to do this
successfully with most of the apply-templates select statement but I'm
having trouble with
one in particular and I'm wondering if this is a bug or if I just can't
figure it out. My
document looks something like
<?xml version="1.0"?>
<ris xmlns="ris.xsd">
<ris-directory-schema>
<!-- lots of these -->
<class type="abstract" id="netscape::top">
<name>Netscape::top</name>
<description>stuff</description>
<attribute ref="#objectClass" required="true"/>
<attribute ref="#aci" required="false"/>
<attribute ref="#description" required="false"/>
</class>
<!-- then lots of these; one for each reference above -->
<attribute-type id="description">
<name>description</name>
<type type="string"/>
<description>stuff</description>
</attribute-type>
</ris-directory-schema>
</ris>
When I am in a template processing the class/attribute element, I need
to select the
attribute-type element that matches the ref= value (minus the #). $attr
is a parameter
which is the ref= value without the #.
If I take the namespace out I can successfully match using
<xsl:apply-templates select="//attribute-type[@id=$attr]"/>
However with the namespace included in the ris element, the following
does not match
<xsl:apply-templates select="//ris:attribute-type[@id=$attr]"/>
I have tried numerous other approaches and can't seem to find anything
that works.
I tried using patterns like
<xsl:apply-templates
select="/from-children(ris:ris-directory-schema)/from-children(ris:attribute-type[from-attributes(id)='acl'])"/>
Note that in this exmple I hardwired the attribute name to aci. All my
attempts at this type
of syntax cause parsing errors. Are from-children and from-attributes
not supported?
I also tried just <xsl:apply-templates select="id($attr)"/>
which seems to match nothing - probably because its expected it to be a
child of the current node.
The documentation is unclear.
Syntax like <xsl:apply-templates select="//id($attr)"/> causing an
exception during parsing.
XSL Error: pattern = '//id($attr)'
Unknown nodetype: id
Remaining tokens: ( '(' '$' 'attr' ')'), style tree node:
org.apache.xalan.xslt.ElemApplyTemplates@c96e431a
XSL Error: Could not parse ris.xsl document!, Location
file:/files/cpsetop/devroot/cpse/ris/apps/xmlxform/ris.xsl, line 105,
offset 48
XSL Error: SAX Exception, Location
file:/files/cpsetop/devroot/cpse/ris/apps/xmlxform/ris.xsl, line 105,
offset 48
Exception in thread "main" org.apache.xalan.xslt.XSLProcessorException:
pattern = '//id($attr)'
Unknown nodetype: id
Remaining tokens: ( '(' '$' 'attr' ')')
at org.apache.xalan.xslt.XSLTEngineImpl.error(Compiled Code)
at
org.apache.xalan.xslt.XSLTEngineImpl.processStylesheet(Compiled Code)
at org.apache.xalan.xslt.XSLTEngineImpl.process(Compiled Code)
at xmlxform.main(Compiled Code)
Any hints would be appreciated. Perhaps there is a simple way to do
this that I just don't know about.
Karen
Re: problem selecting non-child elements when using name spaces
Posted by "Wayne A. Moore" <wm...@stanford.edu>.
Karen Schuchardt wrote:
>
> If I take the namespace out I can successfully match using
> <xsl:apply-templates select="//attribute-type[@id=$attr]"/>
>
> However with the namespace included in the ris element, the following
> does not match
> <xsl:apply-templates select="//ris:attribute-type[@id=$attr]"/>
>
I think you need
<xsl:apply-templates select="ris:attribute-type[@ris:id=$attr]"/>
at least that sort of thing works for me.
Wayne Moore
Re: problem selecting non-child elements when using name spaces
Posted by Martin Gudgin <ma...@develop.com>.
This is a wild stab in the dark but...
Have you specfied xmlns:ris="ris.xsd" on the stylesheet element in the .xsl?
Gudge