Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 4th, 2006, 06:28 PM
Registered User
 
Join Date: Jan 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to handle default namespace declaration?

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

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

Code:
<?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.

Code:
<?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?
 
Old January 4th, 2006, 06:49 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
default-xpath-namespace stolte XSLT 1 March 19th, 2008 12:49 PM
Default Namespace - XSLT 1.0 Geierwally XSLT 2 July 9th, 2007 11:08 AM
Dynamic Default Namespace EcceBozo XSLT 2 June 6th, 2007 04:05 PM
Problem with namespace declaration outspaced XSLT 2 April 4th, 2007 06:55 AM
Default Namespace (where is it?) bekim BOOK: ASP.NET Website Programming Problem-Design-Solution 4 June 12th, 2004 03:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.