Alexander Stepochkin wrote:
Hello!
I stumbled across some strange Xalan behaviour.
The following code:


        Document context = DomHelper.parseString(
            "<?xml version=\"1.0\"?>"
            + "\n<root>"
            + "\n11111111"
            + "\n<![CDATA[cdata text]]>"
            + "\n22222222"
            + "\n</root>"
        );
        NodeIterator ni = XPathAPI.selectNodeIterator(context,
"/*/node()", context);
        Node n;
        while ((n = ni.nextNode()) != null) {
            System.out.println(n.getNodeValue());
        }


shows only:
11111111

but my simple XPath "/*/node()" should select all root's
subnodes so I expect:
11111111
cdata text
22222222

Could you please help me?
What is wrong?

There is no notion of CDATA sections in the XPath data model, so DOM documents that contain them have limitations, and this is one of them. I would suggest you put any documents that have CDATA sections through an XSLT identity transformation before you attempt to use Xalan-C and the wrapper around Xerces-C's DOM.

Another alternative would be to enhance the Xalan-C wrapper around the DOM to handle multiple adjacent text nodes, but that's a fair amount of work.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to