Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xml-dev] RE: Namespace use cases

From: Andrew Welch <andrew.j.welch@-----.--->
To: James Fuller <james.fuller.2007@-----.--->
Date: 7/10/2009 8:20:00 AM
> * 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/

_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@l...
subscribe: xml-dev-subscribe@l...
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent