Altova Mailing List Archives>Archive Index >xml-dev Archive Home >Recent entries >Thread Prev - Re: [xml-dev] RE: Namespace use cases >Thread Next - Re: [xml-dev] RE: Namespace use cases Re: [xml-dev] RE: Namespace use casesTo: 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 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
