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 24th, 2007, 12:32 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default weird namespace thing happening

I'm using XSLT via AxKit to process a bunch of XML files into HTML. The code isn't written by me, but I'm trying to understand what it does. Most of it makes sense but there is one weird thing happening.

At some point I call a certain template using
Code:
<xsl:call-template name="..">
Now within the html-output of this template, all the outer html-tags have five extra namespace declarations (e.g. xmlns:xsp="http://apache.org/xsp/core/v1" ). It even happens if I let the template simply display <b>test</b>. From the html-code it makes no sense, the rest of the html validates* and anything just before or after the <xsl:call-template>-tag works fine too. More <xsl:call-template>-tags are used in the xsl-document(s) and they all work fine.

Anyone got any clue what can go wrong?

* well, except for a namespace declaration in the <html>-tag, which I can't get rid of either. But that's not my major concern right now.

 
Old January 24th, 2007, 12:36 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Sounds like you need to use exclude-result-prefixes on the xsl:stylesheet element.

--

Joe (Microsoft MVP - XML)
 
Old January 24th, 2007, 12:41 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Hard to tell exactly without seeing your stylesheet, but remember that when you use a literal result element, all the namespaces declared in the stylesheet in the scope of that LRE are copied to the result tree unless you exclude them using exclude-result-prefixes.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 24th, 2007, 01:43 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your fast reply, both! It helped a lot and pointed me in the right direction.

I have solved the problem by adding an attribute extension-element-prefixes* whose value is a list of all the namespace names, to the <xsl:stylesheet>-tags. Tags, in plural, as the call-template-thing that went wrong was in an included XSL-document. (Apparently, not everything in this document got these weird namespace-attributes, something which still puzzles me, but I'll scrutinize that bit later.)

Just to make sure, this won't do any harm to the website, right?

* http://www.zvon.org/xxl/XSLTreferenc...-prefixes.html

 
Old January 24th, 2007, 01:55 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>Just to make sure, this won't do any harm to the website, right?

If your output document uses namespaces only in element and attribute names, then there's no risk in excluding namespace declarations. The system will ignore your request if the result document actually needs the namespace.

But if your output includes things like xsi:type="xs:integer", where the "xs" prefix appears not in an element or attribute name but in content, then excluding the xs namespace would be fatal.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 25th, 2007, 05:06 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

On top of Michael's advice if you want to output XHTML then you'll need to keep that one although exclude-result-prefixes won't exclude a default namespace or one that is actually used, it only excludes unused prfix/namespace mappings.

--

Joe (Microsoft MVP - XML)
 
Old January 26th, 2007, 01:00 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, it works now. Thanks (again) :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
About CSS Chapter 5 the <thing> + <thing> {} part thenetduck BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 0 February 7th, 2007 03:45 AM
What is happening here? code_lover SQL Language 0 January 11th, 2007 07:29 AM
Eight chapter - very strange things happening marjan BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 May 1st, 2004 06:32 AM
Crazy Thing happening Kenny Alligood Access VBA 10 February 17th, 2004 12:26 PM
Getting Simple XML Reading In ASP Happening munkimagik XML 1 June 19th, 2003 09:22 AM





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