[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 03:21 PM 2/7/2005, you wrote:
This should work. Your troubleshooting suggests the template matching "reference" is not getting matched.
You may have seen another thread go by, in which the OP learned that if an element name is in a namespace, even if without a prefix, it has to be prefixed to match:
<xsl:template match="n:reference">...
with xmlns:n declared to match the xmlns namespace declaration in your source.
Could this be the problem here?
Yes, it's but not very likely. This is basic and the same version of Xalan is already doing it correctly thousands of times a day.
No doubt, or your grade-school math teacher, who didn't teach you about XML namespaces. (We're shocked!)
The template isn't getting matched at all ... so the question is why. An incorrect namespace binding could well be the culprit.
Note that in:
and
... the two "child" elements do *not* have the same name, despite appearances.
To make matters worse, the *only* way in XSLT to match the child by name in the second example is with an explicit prefix:
match="n:child" xmlns:n="mynamespace"
... I hope that helps.
Re: [xsl] Transform xhtml to xhtml, convert one tag to another, while preserving rest of file
Subject: Re: [xsl] Transform xhtml to xhtml, convert one tag to another, while preserving rest of file From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Mon, 07 Feb 2005 15:29:01 -0500 |
Peter, Peter,
At 03:21 PM 2/7/2005, you wrote:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" omit-xml-declaration="yes" />
<xsl:template match="reference">
<a href="{@page}"><xsl:value-of select="text()" /></a>
<!-- I've also tried <xsl:comment>test</xsl:comment> and <xsl:text>test</xsl:text> as the only contents of the template -->
</xsl:template>
<xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template>
</xsl:stylesheet>
This should work. Your troubleshooting suggests the template matching "reference" is not getting matched.
You may have seen another thread go by, in which the OP learned that if an element name is in a namespace, even if without a prefix, it has to be prefixed to match:
<xsl:template match="n:reference">...
with xmlns:n declared to match the xmlns namespace declaration in your source.
Could this be the problem here?
I'm using Xalan (integrated with Apache Ant) for my transformations. Could this have _anything_ to do with it?
Yes, it's but not very likely. This is basic and the same version of Xalan is already doing it correctly thousands of times a day.
Or am I at fault?
No doubt, or your grade-school math teacher, who didn't teach you about XML namespaces. (We're shocked!)
I'd show the XHTML file that needs to get processed and the <reference> template, but their both quite big, and don't seem to have anything to do with it, since I don't get any warnings or errors.
The template isn't getting matched at all ... so the question is why. An incorrect namespace binding could well be the culprit.
Note that in:
<element> <child/> </element>
and
<element xmlns="mynamespace"> <child/> </element>
... the two "child" elements do *not* have the same name, despite appearances.
To make matters worse, the *only* way in XSLT to match the child by name in the second example is with an explicit prefix:
match="n:child" xmlns:n="mynamespace"
... I hope that helps.
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Transform xhtml to xhtml,, Peter O. | Thread | Re: [xsl] Transform xhtml to xhtml,, Peter O. |
Re: [xsl] Transform xhtml to xhtml,, Peter O. | Date | Re: [xsl] Transform xhtml to xhtml,, Joris Gillis |
Month |