[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xsl / xpath and namespaces

Subject: xsl / xpath and namespaces
From: Jeb Boniakowski <jeb@xxxxxxxxxxx>
Date: Fri, 14 Jan 2005 20:48:34 -0500
xpath and namespaces
Thanks to everyone for the very informative followups to my last post (sorry about the busted subject line, Tommie). I took <xsl:template match="text()"/> out of all of my sheets.

I'm having trouble with transformations involving namespaces though.

All of my xsl files begin with a preamble that I've till now considered a magic incantation generated by my editor. It includes a number of statements that assign namespaces to various prefixes like xsl, xs, xn, xdt, etc. There is no assignment for the default namespace.

So I've been cruising along making xml docs and xsl transformations with no xmlns= at all. I now realize I may have erred.

If I'm transforming one of my namespaceless docs with one of my namespaceless sheets, everything is fine until I <xsl:apply-templates select="document()"> a sheet with an xmlns="something" on its root node. If I remove this attribute from the root node, all is well, but that's more of a phenomenon than a solution.

I had assumed that this was simply a matter of matching the values of xmlns in all my various documents' root nodes. I tried this but it doesn't work. If I have:


and run it through:
<xsl:template match="/">

<xsl:template match="root">

<xsl:template match="child">
 child processed

I get my expected output of:

child processed

child processed

If I add:
xmlns="foo" to <root> and <stylesheet> though, I get:



The result of the default rules, I imagine.

I also tried changing the attribute on the stylesheet to xpath-default-namespace="foo" because I thought 'hey, these Exprs are all XPath, right?". That does nothing.

The only thing that seems to do what I want is to assign a foo prefix in the namespace to the desired ns, and then prepending all the XPath Exprs with foo:. This is not what I want to do though. I just want my stylesheet and source docs to all be in the same namespace, with no prepending of anything. The stylesheets are already written with all the xsl tags prefixed with xsl: so I don't see how there's a potential problem with namespace collision.

Thanks in advance for any help.

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.