Re: a question of DOMSource

Christoffer Dam Bruun <[email protected]> Mon, 06 Jun 2011 11:51:57 +0200
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <[email protected]>
Hi,

If your xpath expressions starts with '/'  e.g. '/Records/Record' then 
you need a document  If you are
transforming a "sub" element you cannot start with '/' e.g. '/Record' 
but must use 'Record'

Best regards
Christoffer Bruun

On 04-06-2011 07:07, ext2 wrote:
>
> Hi:
>
> When I using Xalan 2.7.1 to transform a DOM Source;
>
> I find that:The Node combine with DOMSource must be a Document and It 
> cannot be just a Element;
>
> Does anyone know if this limit is correctly or wrong, and why?
>
> Following is a simple program to illustrate it
>
> Document doc = DocumentBuilder.parse(...)
>
> //if I using document as input, the result is correct;
>
> Transformer.transform(new DOMSource(doc), streamResult);
>
> //but if I using element as input, the result is wrong;
>
> Transformer.transform(new DOMSource(doc.getDocumentElement), 
> streamResult);
>
> Ps: xml  xslt I used:
>
> Xml:
>
> <?_xml_ version="1.0" encoding="UTF-8"?>
>
> <Record _xmlns_="http://www.tongtech.com/tiwen/record1">
>
> <content1>a</content1>
>
> <content2>b</content2>
>
> <content3>c</content3>
>
> </Record>
>
> Xslt:
>
> It's too long, but it logical is very simple, just exchange field 
> content2 & content 3;
>
> And I am sure it's correctly, because I have use a 
> StreamSource(xml-stream), and Document 's DOMSource as input, their 
> result both are correctly;
>
> but if anyone interest with it, I can post it in reply;
>