RE: RE: RE: [xsl] Numbered Elements

Subject: RE: RE: RE: [xsl] Numbered Elements
From: cknell@xxxxxxxxxx
Date: Sun, 04 May 2003 22:26:38 -0500
It's not clear what you want to get from the template. You are asking for the template to match the <etd:xRef> element. This is now your context node. Any xsl function or element inside the template assumes that any XPath expression you use is relative to that context unless you start it with "/", in which case it would be an absolute path.

So this 
<xsl:apply-templates select="etd:xref/@etd:RefElemType"/>
is asking the processor to apply templates to any "etd:RefElemType" attribute which is an attribute of an "etd:xref" element which itself (because the context node is already "etd:xref") a child of an "etd:xref" element.

Do you have a template that matches "etd:xref/etd:xref/@etd:RefElemType"? Probably not. Probably you want to do something with the value of the "etd:RefElemType" attribute which is an attribute of an "etd:xref" element, or you want to process only those "etd:xref" elements which have an "etd:RefElemType" attribute. In the latter case, the XPath would have a predicate like this, "etd:xref[@etd:RefElemType]".

Please clarify.
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     "Jack Cane" <jwcane@xxxxxxxxxxx>
Sent:     Sun, 4 May 2003 15:56:45 -0400
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  RE: RE: [xsl] Numbered Elements

Needless to say, this is all still new to me. I am trying to gain the
minimum knowledge to get my project published, and now realize that this
minimum is "substantial". I started with a tool that added a default prefix
to my local namespace declaration, but only in the stylesheet. I also used
the tool to generate the first sample of xml code, but the tool did not add
prefixes to any of my custom tags in the xml source, and, up to now, my
stylesheet had been transforming all of my custom elements, with no prefix
in the xml source. (More recently I replaced the default prefix with etd,
which is more descriptive of my project.)

Some time ago I encountered some limitations in the tool and, as recommended
here, stopped using it. I have found the text-only approach to be much more
transparent and more instructive.

In response to your latest message, I added my namespace prefix to the tags
in my xml source, and all content is again being transformed as expected,
EXCEPT for the xRef element. Today I exchanged one of my three XML
references for a copy of Michael Kay's 2nd edition, found a clear
explanation of xpath and how one should refer to attributes, and attempted
an implementation.

Now, the xml source is:

<etd:Text>
where, as shown in
	<etd:xRef
		etd:refElemID="FirstSum"
	etd:refElemType="Equation">
	</etd:xRef>, the web application is designed to interact with...
</etd:Text>.

The following xslt template is supposed to return the value of the
<<refElemType>> attribute, and the number of the equation having a
<<Target>> attribute of <<FirstSum>>.

<xsl:key name="kEqn" match="Equation" use="Target" />
<xsl:template match="etd:xRef">
	Eequationn  <!- Plain text, debugging aid, to be sure the template is
functioning; it is -->
	<xsl:apply-templates select="etd:xref/@etd:RefElemType"/>
	<xsl:apply-templates select="xref/@RefElemID"/>
	<xsl:apply-templates select="key('kEqn', '@RefElemID')"/>
</xsl:template>

Since I could not find any examples using a locally defined namespace
prefix, I wrote the first two <<apply-templates>> lines above, with and
without the prefix. None of the three apply-templates elements returns any
text. Maybe you can, again, show me what is still wrong. Appreciate your
help.

jwc


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of cknell@xxxxxxxxxx
Sent: Sunday, May 04, 2003 10:25 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: RE: [xsl] Numbered Elements

> -----Original Message-----
> From:     "Jack Cane" <jwcane@xxxxxxxxxxx>
>

So this is an example of an <xRef> element?
> <xRef>
>   <RefElemID> FirstSum </RefElemID>
> </xRef>

If this is what you mean, please note that the <xRef> element is *not* in
the "etd" namespace. If it were, the element name would have the namespace
and the local name and the element as it appeared in your XML data document
would instead look like this:

<etd:xRef>
  <etd:RefElemID> FirstSum </etd:RefElemID>
</etd:xRef>

When your template looks to match "etd:xRef", but only finds "xRef", there
will be no match, and thus, no output.

--
Charles Knell
cknell@xxxxxxxxxx - email


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread