Hi Dave,
You are missing the context.  8^)
When that template is applied, the context is already the top-level book 
element, so the select statement is trying to select /book/book, which does not 
exist.

Also, you have put @xml:lang in the predicate, but you haven't actually 
selected its value.  Your current select says "apply templates to a book 
element that has an @xml:lang", which will process the whole <book> if it has 
the attribute.  It's a good thing it didn't work.  8^)

I would suggest the following:

<xsl:value-of select="/*/@xml:lang"/>

That will select the value of the top-level element's @xml:lang attribute.

If you only want to select if it has such an attribute, then qualify it with a 
predicate before selecting the attribute:

select="/*[@xml:lang]/@xml:lang"



Bob Stayton
Sagehill Enterprises
[email protected]


  ----- Original Message ----- 
  From: Xmplar 
  To: [email protected] 
  Sent: Thursday, December 01, 2011 11:38 PM
  Subject: [docbook-apps] Cannot write xml:lang to content.opf


  I have specified an xml:lang value in a book element (i.e. not within an info 
tag) and need to write that value to the content.opf metadata element. 

  Here is my customisation:

  <xsl:element namespace="http://purl.org/dc/elements/1.1/"; 
name="dcterms:language">
                  <xsl:apply-templates
                    
select="d:book[@xml:lang]|d:article[@xml:lang]|d:part[@xml:lang]" />
                </xsl:element>

  And all I get in content.opf is an empty element:

  <dcterms:language xmlns:dcterms="http://purl.org/dc/elements/1.1/"; />

  What am I missing from the element selection syntax? I'm using 1.76.1, epub2. 
Thanks

  -- 
  Dave Gardiner

Reply via email to