Join Bytes! wrote:
[color=blue]
> Following xsl is used:
> <xsl:stylesheet version='1.0'
> xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
> xmlns:xalan="http://xml.apache.org/xslt"
> xmlns:java="java"
> xmlns:convert="com.foo.Class">[/color]
[color=blue]
> The xml parsed have the followin format:
> <?xml version="1.0" encoding="utf-16"?>
> <MessageHeader xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="http://www.foo2.com/XMLSchema/Envelope">[/color]
The problem is that various elements are in a default namespace defined
with xmlns="namespaceURI" so those elements have a name without a prefix
(e.g. MessageHeader) but are in a certain namespace.
To match that with XPath 1.0 you need to bind a prefix to the default
namespace and use that prefix in XPath expressions and XSLT match
matterns. No change is needed on the XML input but inside of the
stylesheet you need to add e.g.
xmlns:pf1="http://www.foo2.com/XMLSchema/Envelope"
xmlns:pf2="http://www.foo2.com/Schema.xsd"
on the xsl:stylesheet element, then your XPath expressions can look alike
/pf1:MessageHeader/pf2:Message
to select elements in the namespaces bound to the prefixes used.
--
Martin Honnen
http://JavaScript.FAQTs.com/