Altova Mailing List Archives


Re: [xsl] Name Spaces in Selects and xsl:element

From: David Carlisle <davidc@--------->
To:
Date: 5/5/2005 3:27:00 PM
> So, given the sample data, how would one
> select all elements who's namespace is "fn"?

select="//fn:*"

does just what you say 9so long as fn prefix is bound to a namespace in
your stylesheet (the source doesn't have to use the same prefix)

But that probably isn't what you want to do, as selecting all elements
in a single node set isn't usually useful. In this case you'd get fn:A
and all the fn:B's

if you justuse a normal apply-templates then you can make all elements
be discarded
<xsl:template match="*"/>
and then have more specific templates to do something with fn elements,
eg
<xsl:template match="fn:*">
 <xsl:apply-templates/>
</xsl:template>

will produce the result that you wanted.

  Another question, about xsl:element.  When I use this to create
  elements, the elements never get the appended xmlns attribute added. 

note that namespace declarations (xmlns....) are not attributes to
XPath/XSLT (even though they use a similar syntax)


> <NewElement xmlns:ms="urn:schemas-microsoft-com:xslt">
> How can this be avoided without using the xsl:element command?

Th ms namespace prefix must be in scope in your stylesheet.
If you need it declared but don't need it in the result add
omit-result-prefixes="ms"
to your xsl:stylesheet element.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.