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 February 22nd, 2012, 02:04 PM
Authorized User
 
Join Date: Oct 2011
Posts: 30
Thanks: 2
Thanked 0 Times in 0 Posts
Default exclude-result-prefixes

Hi guys,

I am having an issue with the exclude-result-prefixes functionality it xslt.

I am including an fpml library in my code.. but every fpml elelemnt comes with the

web site after it.

ie
Code:


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fpml="http://www.fpml.org/2008/FpML-4-5"
    exclude-result-prefixes="fpml" >
But I am still getting the following

- <fpml:trade xmlns:fpml="http:=//www.fpml.org/2008/FpML-4-5">


when what i really want is

- <fpml:trade>


Code:
<xsl:element name ="fpml:trade">
I have added the exclude_result_prefix.. but it just will not go away......
Can I have some advice please

thanks
 
Old February 22nd, 2012, 03:35 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

exclude-result-prefixes only excludes unused prefixes, and will not exclude a used prefix as that would result in an invalid XML document.

Try including the namespace declaration on the root output object, and then it might not get included in child elements, so you will only see it once, which certainly looks cleaner.

Without seeing more of your input or output it is hard to give more advise.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old February 23rd, 2012, 05:32 AM
Authorized User
 
Join Date: Oct 2011
Posts: 30
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Hi Sam.. am not sure what you mean by this.....
how could i include it once in the root of the xml.....
Can you expalin by example pls
thanks
 
Old February 23rd, 2012, 06:09 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The document

<fpml:trade/>

without a namespace declaration would be ill-formed (according to the XML Namespaces specification), and XSLT is designed to make it impossible to produce ill-formed output. So there's no way to do this - and no reason to want to.

The attribute exclude-result-prefixes can be used to eliminate unused namespace declarations from your output, but it can't be used to eliminate declarations that are necessary for the document's integrity.
__________________
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
Not using Namespace prefixes stuohy XSLT 6 June 19th, 2012 04:23 PM
exclude-result-prefixes="#all" and xsi:type maxtoroq XSLT 2 November 7th, 2008 08:46 PM
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
how to exclude elements in the result tree output ntmt XSLT 0 May 25th, 2006 10:33 AM
maximum number of prefixes? gumgak ASP.NET 1.0 and 1.1 Basics 5 February 13th, 2006 09:56 AM





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