If I could clarify Wendell's response a little: XSLT 1.0 in general
allows the XSLT processor (or more specifically, the serializer) to use
whatever prefixes it wants - though in practice, processors only take
advantage of this in edge cases. XSLT 2.0 makes the choice of prefix
predictable in the vast majority of cases: for example if you have a
literal result element <p:xyz> in the stylesheet, then the prefix p will
be used in the output. The reason for this change is two-fold: firstly,
XML is designed to be human-readable, and prefixes matter to human
readers. Secondly, prefixes can be used in content, for example the
infamous xsi:type="my:ownType". This only works if there is a
declaration for the prefix "my" in the document, so the XSLT author
needs to be able to guarantee that "my" will not be replaced by "your".
Michael Kay
Saxonica
On 08/02/2012 22:01, Wendell Piez wrote:
Ram,
Maybe you want to use xsl:copy, which may do better for you. Most
processors, when copying an element, will use the same prefix as the
input document uses.
Or it may not: as Ken says, processors are not obliged to respect
prefixes since a prefix is not properly part of the name, as formally
defined; it is only a (local) binding mechanism.
If you are answering a requirement from a partner who does not
understand this, you can, in XSLT 2.0, go to considerably more work to
construct elements with namespaces, names and their prefixes generated
dynamically, using XPath functions such as name(),
prefix-from-QName(), and namespace-uri-for-prefix(). An XSLT
stylesheet could generate a new header using whatever prefix the input
uses, whatever it is -- although such a stylesheet will look pretty
mysterious to the uninitiated.
But this is not trivial to do, and a lot of trouble to go to for
something that matters only because someone thinks it matters. Even
worse, if you are addressing a set of requirements that have never
been articulated, which you have only because someone at some point
might be unhappy about something ... well. That's a difficult problem
to solve.
Cheers,
Wendell
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--