xsl-list
[Top] [All Lists]

Re: XHTML->XHTML w/ XSLT, modifying only specific element(s)

2004-10-24 15:03:42
At 2004-10-24 12:38 -0700, Evan Nemerson wrote:
I'm trying to use XSLT to transform XHTML to XHTML, modifying only specific
elements in the process--specifically, I want to append a link within
blockquote elements which uses the cite and title attributes of the
blockquote tags. Here's what I have right now:

You are heading in the right direction.

  <xsl:template match="blockquote[(_at_)cite and @title]">

I suspect you want match="xhtml:blockquote[(_at_)cite and @title]" ... though you don't give a snippet of your input XHTML, you probably are using the default namespace. XPath 1.0 does not use the default namespace.

      <a class="serendipity_blockquoteReferenceLink">
        <xsl:attribute-set name="href"><xsl:value-of
select="@cite"/></xsl:attribute-set>
        <xsl:value-of select="@title"/>
      </a>

BTW, you could use:

   <a class="serendipity_blockquoteReferenceLink"
      href="{(_at_)cite}">
     <xsl:value-of select="@title"/>
   </a>

The instruction was also incorrect: you could have used <xsl:attribute> not the <xsl:attribute-set> that you used, but my use of the attribute value template is more succinct.

Nothing I put in that second xsl:template element seems to have any effect.

I'm guessing that your input has a namespace associated with the default namespace ... your element names are not prefixed but your qualified names probably have non-null associated namespace URIs. The way you wrote your template rule was matching "blockquote" in no namespace, not "blockquote" in the XHTML namespace.

Sorry to post such a simple question, but I'm completely stumped.

It is a FAQ to ask why a non-prefixed element name in a match is not matching elements from a namespace.

I hope this helps.

....................... Ken

p.s. Note that XSLT 1.0 does not specify an XHTML output method, only an XML output method, so you will get an XML result, but you won't get an XHTML result.

--
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal