This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Exclude result prefixes


David Morris wrote:

>I was trying to clean up some generated xhtml and decided to get rid
>of some extra namespace declarations.  I tried to use the 
><xsl:exclude-result-prefixes> to get rid of some namespace declarations
>for namespaces that are not part of my output documents. This removed
>the unneccesary namespaces declaration from the element that I used it
>on (the root), but that just made caused the declaration to come back
>on the root's children.
>
>Thanks,
>
>David Morris
>
Two ideas:
When you say you put it on 'the root', do you mean the literal result
element which is to be the root of the output document, or the
xsl:stylesheet element?  (If you are using 'literal result element as
stylesheet' these are the same so ignore this bit).  Its usual to put
exclude-result-prefixes on the xsl:stylesheet - I don't think it
should make a difference, but you might try it.

My second guess is that you are using xsl:copy or xsl:copy-of.  The
problem is that these copy all the namespace nodes present.  Remember
you get a namespace node on an element for all namespaces declared on
that element *or* any of its ancestors: they do not just appear where
the actual declaration is.  There are two ways round this that I know
of:
  a) move the namespace declarations in the stylesheet or source
document so they do not appear on the nodes you are copying (not
always possible or practical)
  b) use xsl:element instead of xsl:copy (messy but it works) or
xsl:copy-of (even messier).

Or just live with it ;-)

Regards,
Trevor Nash

--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@melvaig.co.uk

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]