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 July 30th, 2010, 08:34 AM
Authorized User
 
Join Date: Feb 2009
Posts: 31
Thanks: 6
Thanked 1 Time in 1 Post
Send a message via MSN to anil_yadav26@hotmail.com
Default "xmlns" not allowing to work

Hi,

In one of my project the xml files have the “xmlns” attribute/namespace in the root element. But XSL’s match command is not recognizing it and If I removed that "xmlns" from the root element the XSLT works file. Can anybody please suggest how I can allow this in XSLT?

Below is the XML, XSLT and OUTPUT.

Thanks,
Anil Yadav

XSLT
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform 
xmlns:xlink=http://www.guideposts.com
xmlns=http://docbook.org/ns/docbook
version="1.0">
<xsl:template match="book">
<xsl:text>**BOOK**</xsl:text>
</xsl:template>
</xsl:stylesheet>
XML
Code:
<?xml version="1.0" encoding="UTF-8"?>
<book xmlns="http://docbook.org/ns/docbook">
<title>The Best Medicine</title>
</book>
OUTPUT Required
Code:
**BOOK**
 
Old July 30th, 2010, 08:43 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

See the first post in this category, Hints for a good XSLT post.

Especially the bit towards the end about selecting elements in a namespace.
__________________
Joe
http://joe.fawcett.name/
 
Old July 30th, 2010, 08:56 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Or just google for "XSLT FAQ default namespace". The key thing to note is that a default namespace declaration puts all your element names in a namespace, and unprefixed names in the stylesheet are searching for element names in no namespace.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Difficulties with "web.config" and "ASPNETDB" CFRham BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 2 July 3rd, 2010 10:19 AM
Can't get "ASP.NET configuration" to work in the examples. Javaman BOOK: Professional C# 2008 ISBN: 978-0-470-19137-8 1 November 3rd, 2009 02:34 PM
How to theme the "Browse" button of "FileUpload" control? varunbwj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 October 14th, 2009 01:22 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 03:09 PM





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