Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 7th, 2008, 12:46 PM
Registered User
 
Join Date: Oct 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default exclude-result-prefixes="#all" and xsi:type

# given the following input doc:
<foo></foo>

# run through this stylesheet:
<xsl:stylesheet version="2.0" exclude-result-prefixes="#all"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:A="urn:A">

    <xsl:output indent="yes"/>

    <xsl:template match="/">
        <bar xsi:type="A:AType">
            <xsl:value-of select="text()"/>
        </bar>
    </xsl:template>

</xsl:stylesheet>

# produces this result (Saxon-B, AltovaXML)
<bar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="A:AType"/>

The problem with the result document is that it doesn't include the namespace declaration for the 'A' prefix, used in xsi:type. If I remove exclude-result-prefixes="#all" then it IS included.

Anyone had a similar issue before? exclude-result-prefixes must be used with care considering this behaviour.
Reply With Quote
  #2 (permalink)  
Old November 7th, 2008, 12:53 PM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Well the result is correct in terms of the namespace declarations and namespaces used for element and attribute names. I don't think attribute values are relevant to how the XSLT serializer works.

--
  Martin Honnen
  Microsoft MVP - XML
Reply With Quote
  #3 (permalink)  
Old November 7th, 2008, 08:46 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If the system knew exactly which namespaces were used in your result document, then exclude-result-prefixes wouldn't be necessary. It's provided because the system doesn't know. Obviously if you exclude result prefixes that shouldn't have been excluded, you must take the consequences.

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with xsi:SchemaLocation akshay144 XML 2 August 20th, 2008 05:40 AM
xsl:exclude-result-prefixes #all and #default maxtoroq BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 4 July 28th, 2008 12:10 PM
Creating xsi:type as an attribute AjayLuthria XSLT 5 May 10th, 2007 09:49 AM
how to exclude elements in the result tree output ntmt XSLT 0 May 25th, 2006 10:33 AM
copy-of xsi namespace chris_strub XSLT 2 October 2nd, 2004 10:32 PM



All times are GMT -4. The time now is 10:51 AM.


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