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

Re: Ignore namespaces

Subject: Re: Ignore namespaces
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 28 Jun 2002 11:33:44 +0100
xpath ignore namespace
Hi Filipe,

> I have a pretty complex XSL prepared to work with an XML input
> without namespaces.
>
> Now I want to use an XML document with namespaces in some of its
> elements but those namespaces should be ignored by the XSL and the
> elements processed as if no namespace existed.
>
> Is there an easy way to do this?

Unfortunately not in XSLT 1.0. As far as XPath and XSLT are concerned,
an element with a namespace is completely different from an element
without a namespace. To change an XSLT 1.0 stylesheet from working
over a source document without namespaces to one with, you have to
change every XPath that refers to elements that now have a namespace,
so that they include prefixes pointing to that namespace.

Because this is a common problem, XSLT 2.0 has an attribute,
'default-xpath-namespace', which you can use to tell the XPath
processor that any element name tests without prefixes in XPaths
should count as selecting/matches elements in that default XPath
namespace rather than in no namespace. So come XSLT 2.0 you'll be able
to just slide your new namespace into that attribute and everything
(well, assuming that *all* your elements were in that namespace) would
work fine.

> Perhaps the best would be to make some sort of pre-processing and
> remove all namespaces before applying the XSL.
>
> I'm trying to avoid changing the way my XSL works because I guess it
> won't be that easy (or maybe it is...?)

If you want to carry on being able to process the original documents,
that didn't have a namespace, then a pre-processing step would be
sensible (and isn't hard to do in XSLT). If you now *only* want to use
the documents with namespaces as the source, you may as well change
the XPaths; it'll probably be simpler in the long run, and more in the
spirit of the namespace use.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.