exclude-result-prefixes="xmlns"
In .net, the following xslt is right.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
exclude-result-prefixes="table xmlns">
but in java, if I use saxon,
exclude-result-prefixes="xmlns"
开发者_如何学Go
will generate the following error:
Error at xsl:stylesheet on line 52 of worksheets.xsl: XTSE0165: Namespace prefix xmlns has not been declared
Firstly, the rather dry question of which product is right. The XSLT 1.0 specification says of exclude-result-prefixes, " It is an error if there is no namespace bound to the prefix on the element bearing the exclude-result-prefixes or xsl:exclude-result-prefixes attribute. " The namespace prefixes that are "bound" (in scope) for an element are as defined in the XPath data model http://www.w3.org/TR/xpath/#namespace-nodes, which if you read it extremely carefully tells you that there is no in-scope binding for the prefix "xmlns". XPath 2.0 spells it out much more clearly: "A Namespace Node must not have the name xmlns nor the string-value http://www.w3.org/2000/xmlns/.", but this is intended as a clarification rather than a substantive change.
Now the more interesting question of how to achieve what you are trying to achieve. I don't think you have actually told us what you are trying to achieve. Some responses have speculated that exclude-result-prefixes="#default" will solve your problem, but before advising that, I would quite like to know what your problem is.
According to XSLT spec, use #default
, e.g.: exclude-result-prefixes="#default"
.
Reference: http://www.w3.org/TR/xslt#literal-result-element
Including xmlns in exclude-result-prefixes is in error, the Xml spec forbids declaring the xmlns
namespace prefix explicitly:
The prefix xmlns is used only to declare namespace bindings and is by definition bound to the namespace name http://www.w3.org/2000/xmlns/. It MUST NOT be declared . Other prefixes MUST NOT be bound to this namespace name, and it MUST NOT be declared as the default namespace. Element names MUST NOT have the prefix xmlns.
Therefore, it doesn't make sense to include xmlns in exclude-result-prefixes
because it is not a valid prefix. For more information, see http://www.w3.org/TR/xml-names/#ns-decl
精彩评论