xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas B. Passin" <tpas...@mitretek.org>
Subject Re: xlink:href
Date Mon, 17 Apr 2000 15:23:05 GMT

Christian A. Calmeyer asked for help with an XSLT/Xerces problem
(reproduced below)


Christian, I couldn't get your example to work with XT either.  I
discovered that
1) I had to include the xlink namespace declaration in the stylesheet,
and
2) The real trouble was caused by the use of a default namespace. XT did
not recognize the <image> tag when it was specified in the <xsl:template
match=""> statement.

I got the stylesheet to work  when I changed the default namespace to
use a prefix (I used "i").  Notice that I did not have to change the XML
document, just the stylesheet.  It seems that XT needs to have some
definite prefix or it can't match up namespaces.  I don't know if this
is a bug or the correct behavior.

Why don't you try my version of your example - I know it works with XT.
Here it is:

----------- Source XML: -------------
<document xmlns="http://xxxxx/"
xmlns:xlink="http://www.w3.org/1999/xlink/">
<image xlink:type="simple" xlink:href="xxx.jpg"/>
</document>

----------- Stylesheet: ---------
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'
xmlns:i="http://xxxxx/"
xmlns:xlink="http://www.w3.org/1999/xlink/">

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="i:image"> <!--Yes, this looks wrong but it
works!-->
<xsl:element name="img">
   <xsl:attribute name="src">
      <xsl:value-of select="@xlink:href"/>
   </xsl:attribute>
</xsl:element>
</xsl:template>

</xsl:stylesheet>


Would someone who understands xslt better than I please tell us if this
is the behavior intended by the rec or not?

Regards,
Tom Passin

========================================================================
===
I have difficulties mapping a 'xlink:href' attribute to HTML 'src'
attribute (or 'href' for that matter),
usingXerces-J 1.0.3 / Xalan 1.0.1.

The transformation looks like:

<img>
<xsl:attribute name="src">
<xsl:value-of select="@xlink:href"/>
</xsl:attribute>
</img>

The xml source is
<image xlink:type="simple" xlink:href="xxx.jpg"/>

Namespaces are declared in the root element:
<document xmlns="http://xxxxx/"
xmlns:xlink="http://www.w3.org/1999/xlink/">

Using <img src="{@xlink:href}"> or any other combination won't work
either. You must excuse my ignornance, but after browsing mailinglists
and standards, I still can't a way around this problem (apart for
skipping the namespace).

========================================================================
================


Mime
View raw message