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

Re: RE: Namespace use cases

  • From: Andrew Welch <andrew.j.welch@gmail.com>
  • To: James Fuller <james.fuller.2007@gmail.com>
  • Date: Fri, 10 Jul 2009 09:19:05 +0100

Re:  RE: Namespace use cases
> * Pitfalls: whats in the default namespace ? should I use an attribute
> or element ? should I embed versioning or any kind of metadata within
> namespace URI ? I don't want to sound like an XML Namespace
> 'apologist' but doesn't every concept have its dark corners and
> nuances to trip up on ?

A common dark corner or nuance is XSLT is generating XHTML (or XForms etc):

<xsl:template match="/">
 <html xmlns="http://www.w3.org/1999/xhtml">
   <xsl:apply-templates/>
 </html>
</xsl:template>

<xsl:template match="foo">
 <body>asdf</body>
</xsl:template>

generates

<html xmlns="http://www.w3.org/1999/xhtml">
  <body xmlns="">asdf</body>
</html>

The <body> element is in no namespace, because the namespace is scoped
in the XML-document-that-is-the-stylesheet, not in the XSLT processor
itself, which is non-intuitive for most.

The solution is to ensure that the <body> element in the foo matching
template is in scope for the default namespace change, either by
adding another xmlns declaration, or by moving the the existing one up
to a common ancestor, so you end up with:

<xsl:template match="/">
 <html>
   <xsl:apply-templates/>
 </html>
</xsl:template>

<xsl:template match="foo">
 <body>asdf</body>
</xsl:template>

So no namespace in sight, the xmlns is defined higher up on
xsl:stylesheet).  So now to the unaware it seems you are generating
output in no namespace, but in fact all unprefixed elements are in the
correct namespace...

I can't see a way around this at the moment, just pointing it out as a
common problem...


--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.