Hi, Jiang: According to Apache Xalan's answer, I need to change xslt script to remove prefix "/" while using DOM as input;
And it still cannot work with SUN's latest JAXP release; Anyway, it's SUN's problem, and maybe a issue of Servimix's user. This is nothing to do with camel; Thanks > -----original ----- > Sender: ext2 [mailto:x...@tongtech.com] > Date: 2011/6/8 11:09 > Receiver: users@camel.apache.org > Subject: Re: A problem of XSLT > > Hi, Jiang: > I just got the answer from apache xalan mail-list. You can check it; > > Following is the apache xalan's response: > > >Sender: Christoffer Dam Bruun [mailto:cdbr...@flyingpigs.dk] > >Date: 2011/6/6 17:52 > >Receiver: xalan-j-us...@xml.apache.org > >Subject: Re: a question of DOMSource > > >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; > > > > > > -----original ----- > >Sender: Willem Jiang [mailto:willem.ji...@gmail.com] > >Date: 2011/6/7 16:51 > >Receiver: users@camel.apache.org > >Subject: Re: A problem of XSLT > > > > As you can't tell if there are some problems in your XSLT template, > > can you write a simple java code to call transformer yourself? > > > > On 6/4/11 12:38 PM, ext2 wrote: > > > Hi: > > > > > > Recently I am using camel xslt to do xml transform; > > > > > > If the xslt processor's input is a xml string, the transform result is > > > correct; > > > > > > But if the xslt processor's input is a org.w3c.xml.Node which is build > from > > > the exactly same xml string; then thing's will be very strange: > > > > > > If I using the latest sun's JAXP implementation , a exception (Namespace > for > > > prefix has not been declared) always occurs; and if I switch to apache > > > xalan 2.7.1,the transform result is just a empty document; > > > > > > Actually, I think this problem is the XSLT engine's reason; > > > But after I explorer the source code of xalan, I find it seems xalan > always > > > ask for the input DOM Node should be a document container. I am not sure > if > > > this limit is a bug or a correct thing; > > > Do anyone know it? > > > > > > If the limit is correctly, Maybe the camel XSLT processor should wrapper > a > > > DOM with a DocumentFragment, then build a DOMSource of DocumentFragment > as > > > XSLT's input; > > > But if the limit is xslt engine bug, maybe we should waiting from xalan > or > > > sun to correct this; > > > > > > > > > Ps: route& xml& xslt; > > > Route:( same route from DOM input& xml string input) > > > <from uri="direct:from"/> > > > <to uri="xslt:test/test.xsl?output=DOM"/> > > > <to uri="mock:result/> > > > > > > > > > Xml: > > > Input: > > > <?xml version="1.0" encoding="UTF-8"?> > > > <Record xmlns="http://test/record1"> > > > <content1>a</content1> > > > <content2>b</content2> > > > <content3>c</content3> > > > </Record> > > > > > > Successful result: > > > <?xml version="1.0" encoding="UTF-8"?> > > > <tag0:Record xmlns:tag0="http://www.tongtech.com/tiwen/record1"> > > > <tag0:content1>a</tag0:content1> > > > <tag0:content2>c</tag0:content2> > > > <tag0:content3>b</tag0:content3> > > > </tag0:Record> > > > > > > Xslt: > > > .....it's too long, and I am sure it's correct....; > > > > > > > > > > > > > > > -- > > Willem > > ---------------------------------- > > FuseSource > > Web: http://www.fusesource.com > > Blog: http://willemjiang.blogspot.com (English) > > http://jnn.javaeye.com (Chinese) > > Twitter: willemjiang > > Weibo: willemjiang >