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

Re: template pattern does not get matched properly wit

Subject: Re: template pattern does not get matched properly with xmlns declaration
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 18 Jan 2001 16:27:37 +0000
template pattern
Hi Helen,

> However after I removed xmlns declaration(i.e xmlns="
> http://www.ipdr.org/namespaces/ipdr" part) from IPDRDoc element
> in test.xml, everything is just working fine. I have no idea what's wrong with
> the xml/xsl test files.

The fact that taking the default namespace declaration out changed
things indicates that it's a namespace issue.  Because of the default
namespace declaration, all the elements that don't have a prefix are
placed in the 'http://www.ipdr.org/namespaces/ipdr' (IPDR) namespace.

Now, in your stylesheet you match against IPDRDoc elements but don't
specify a prefix for them.  If you don't specify a prefix when you're
matching/selecting an element, then it assumes you mean an element in
the *null* namespace.  The IPDRDoc element in the IPDR namespace
isn't an IPDRDoc element in the null namespace, so it doesn't match
that template, and the built in templates are used all the way
through.

To get around this, you need to declare the IPDR namespace (with a
prefix) within the XSLT stylesheet. Something like:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:ipdr="http://www.ipdr.org/namespaces/ipdr">
...
</xsl:stylesheet>

Then, whenever you want to refer to an element in that namespace, you
have to use the prefix you've assigned to it (ipdr in this case)
within the name.  For example, the match pattern for the template
should be:

<xsl:template match="ipdr:IPDRDoc">
   ...
</xsl:template>

By the way, space is preserved within all elements in your source by
default, so:

<xsl:preserve-space elements="text" />

won't have any effect unless you also tell it to strip spaces for the
'text' element, perhaps by telling it to strip spaces for *all*
elements through something like:

<xsl:strip-space elements="*" />

I don't see any 'text' elements in your source, though, so I'm not
exactly sure why you've got this instruction in the first place?

I hope that helps,

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.