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 22nd, 2009, 01:28 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default Exclude a namespace with no prefix

Hi,

I have a names space:

xmlns="urn:schemas-microsoft-com:office:spreadsheet"

How do exclude it from my output since there is no prefix?

e.g.

exclude-result-prefixes="fo ss o x #default"

thanks
 
Old January 22nd, 2009, 01:38 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You seem to have guessed the syntax correctly: "#default".
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old January 22nd, 2009, 01:38 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Does the #default not do what you want?
What exactly are you trying to achieve? Can you show us the relevant parts of your stylesheet?
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old January 22nd, 2009, 02:44 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Ok, I tried #default in both xmlspy and saxon.

I have an ms excel xml file with the following namespaces:

<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">


I am able to exclude all but:

xmlns="urn:schemas-microsoft-com:office:spreadsheet"


Any thoughts
 
Old January 23rd, 2009, 07:40 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Well exclude-result-prefixes does not change the namespace of elements in your XML input document.
What is it that you want to achieve?
If you want to process elements in the namespace urn:schemas-microsoft-com:office:spreadsheet like that Workbook element and want to strip the namespace then you need to write a template for that e.g.
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0"
  xmlns:mss="urn:schemas-microsoft-com:office:spreadsheet">

  <xsl:template match="mss:*">
    <xsl:element name="{local-name()}">
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

  ...
But I am guessing what you might want to achieve with the exclude-result-prefixes, it is better you explain what you want to transform your Workbook element to.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
jminatel (January 26th, 2009)
 
Old January 23rd, 2009, 08:05 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

exclude-result-prefixes only excludes a namespace if

(a) the namespace is unused, and

(b) the namespace would otherwise be included in the result by virtue of the rules for literal result elements, that is, an LRE is copied to the result together with all its in-scope namespaces

If the namespace is used in the result document, or if it gets into the result document some other way (e.g. via xsl:copy) then exclude-result-prefixes has no effect.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old January 23rd, 2009, 08:48 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Thanks Michael and Martin.

This is great info. I was able to figure it out by adding a prefix to the namespace (as Martin suggested).
e.g

xmlns:mss="urn:schemas-microsoft-com:office:spreadsheet"

Thanks again.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove namespace prefix from XmlBean ratzko BOOK: Professional Java Development with the Spring Framework 0 August 10th, 2008 01:23 PM
Adding Prefix and Namespace to XML Lerxt XSLT 6 November 8th, 2007 03:14 PM
Exclude Namespace Atribute bonekrusher XSLT 3 May 4th, 2007 08:18 AM
How a additional prefix in a namespace comes? diang BOOK: ASP.NET Website Programming Problem-Design-Solution 0 July 13th, 2006 10:40 PM
attribute namespace prefix tsmith XSLT 1 August 12th, 2004 06:01 AM





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