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 November 7th, 2008, 12:46 PM
Registered User
 
Join Date: Oct 2006
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.
 
Old November 7th, 2008, 12:53 PM
Friend of Wrox
 
Join Date: Nov 2007
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
 
Old November 7th, 2008, 08:46 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
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





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





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