OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook-apps] Something like an attribute-set, but different


> I'm having difficulty getting the desired effect, though (either with  
> params or attribute sets), which I think is due to my  
> misunderstanding of Xpath query syntax.  I've constructed a very  
> small case that illustrates my misunderstanding.
> Within an attribute-set, the following evaluates as true
>    <xsl:when test="/book">
> But the following does not:
>    <xsl:when test="/book/info[1]">
> nor does
>    <xsl:when test="/book/info">

The info element looks like you are using DocBook 5, right? 
In this case the above test is expected to fail, because the
element belongs to no namespace. You need the DocBook5 namespace 
for each element. Insert the following line in <xsl:stylesheet>:


You have to change the XPath expression a bit to take care of the
DocBook5 namespace:

  <xsl:when test="/d:book/d:info[1]">

> I would have thought that, since my <book> contains an <info>  
> element, that the second and third expressions would each return one  
> node, and thus evaluate to true.  This understanding is based on the  
> following example from the W3 XPath specification (http://www.w3.org/ 
> TR/xpath#path-abbrev)

Probably you just missed the namespace.

> "/doc/chapter[5]/section[2] selects the second section of the fifth  
> chapter of the doc"
> I'm sure that I'm making a very basic error here - could someone help  
> me clarify my understanding?

A lot of XML applications like SVG (Scalable Vector Graphics), MathML, 
etc. have a namespace for their elements. Sometimes even for attributes 
(like XLink).
For example, DocBook5 have a title element, but SVG has also one. If
you integrate a SVG graphic into a DocBook document, there is a
"name collision": Both have the same name, but comes from a different
Schema. To differentiate it, that's the reason for
a XML namespace:

  <title xmlns="http://docbook.org/ns/docbook";>...</title>
  <title xmlns="http://www.w3.org/2000/svg";>...</title>

The xmlns (for "XML Namespace") shows you which element belongs to 
which namespace. This is the reason why XSLT treated your elements

If you don't see any difference, some XML experts write an element 
name with a namespace like this:


Now I hope you see the difference. :) But that's just for clarification, 
it's not correct XML.

Back to your XSLT problem: If the Schema has its elements (or attributes)
in a namespace so you must declare and use it in XSLT too.

Hope that helps,

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]