Dear All,
I've encountered a further problem with namespaces.
Originally I wanted to have a non-default namespace for literal result
elements in my stylesheet, and the same namespace - but as the default -
in the input and output XML. This doesn't seem to be possible so I've
followed your collective advice and made this the default namespace in
the stylesheet as well. This works for the simple example that I posted
previously.
Unfortunately it fails when I try to match on source document elements.
This problem is a FAQ: match="A" doesn't match A in the source
document if the source document has a default namespace, even if the
stylesheet has the same default namespace.
The normal solution is to use a namespace prefix in the stylesheet, but
that's exactly what I'm avoiding to fix the original problem.
I may have a solution that uses a default namespace and a non-default
namespace in the stylesheet with the same URI; I use the default
namespace in literal result elements and the prefix in match
expressions. It looks like this might work, but it is a
kludge-upon-a-kludge.
Here's an example:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns="http://example.com/foo"
xmlns:f="http://example.com/foo"
exclude-result-prefixes="f">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<root>
<xsl:apply-templates/>
</root>
</xsl:template>
<xsl:template match="f:foo">
<hello/>
</xsl:template>
</xsl:stylesheet>
Input:
<?xml version="1.0"?>
<foo xmlns="http://example.com/foo">
<blah/>
</foo>
Result:
<?xml version="1.0"?>
<root xmlns="http://example.com/foo">
<hello/>
</root>
Can anyone suggest anything better?
--Phil.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--