Subject: How to handle default namespace declaration?
Posted By: moltenlava Post Date: 1/4/2006 5:28:28 PM
I am finding that XML documents that have default namespace declared are not handled by XSLT engine in both Firefox and IE.  Maybe I'm missing something in the xsl to let XSLT engine know about the namespace.  Here's a simple example.

test.xml


<?xml version="1.0"?>
<body xmlns="http://www.w3.org/TR/REC-html40">
  <b>foo bar</b>
</body>


test.xsl


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="body">
    <html>
      <xsl:apply-templates/>
    </html>
  </xsl:template>
  <xsl:template match="b">
    123 456
  </xsl:template>
</xsl:stylesheet>


If I remove the default ns declaration from the xml, it works.


<?xml version="1.0"?>
<body>
  <b>foo bar</b>
</body>


Is there anything I should add to xsl so that it can accept xml documents with default namespace declared?
Reply By: mhkay Reply Date: 1/4/2006 5:49:42 PM
Google for "XSLT FAQ default namespace" and you will soon find the answer to this common problem.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

Go to topic 38292

Return to index page 403
Return to index page 402
Return to index page 401
Return to index page 400
Return to index page 399
Return to index page 398
Return to index page 397
Return to index page 396
Return to index page 395
Return to index page 394