I wrote a xslt to transform one xml format A to another xml format B. During the process, I found if in the source XML A, any element Tag with "xmlns" attribute like <sdc xmlns="http://www.sdc.com"> then I can not fetch the subelemnt value from sdc Node via XSLT. if I delete the xmlns attribute from sdc node, all works fine. Should I change something in my XSLT about the xmlns information? Thanks, Roy
SCJP 1.4/SCBCD/SCWCD<br />MCSE<br />IBM professional XML Developer<br />SAP certified Development Consultant (NetWeaver portal and Web JavaApplication)
The xmlns="foobar" piece, a default namespace definition, in your XML document tells the parser that the element "sdc" is actually "foobar:sdc". In other words, your XSL needs to do
instead of
[ January 14, 2004: Message edited by: Lasse Koskela ]
Thanks, Lasse Koskela but if I can not directly use the template, waht should I do? In my case, the source xml file is like: .... <header> <sdc xmlns="http://www.abc.com"> <gilt> <devel>12567</devel> </gilt> </sdc> </header> ...
How can I modify the XSLT with the xmlns? Like: .... <develLc> <xsl:value-of select="header/sdc/gilt/devel"/> </develLc> ... to fecth the value 12567?
Roy
SCJP 1.4/SCBCD/SCWCD<br />MCSE<br />IBM professional XML Developer<br />SAP certified Development Consultant (NetWeaver portal and Web JavaApplication)
Hi, Lasse, I have tried the exact same procedure before I asked you agin with the last reply. But it always gets a Java IO Null Point Exception, the value 12567 is not fetched. I use XALAN XSLT, but if I delete the xmlns in Source XML, everything goes fine. Any idea? Roy
SCJP 1.4/SCBCD/SCWCD<br />MCSE<br />IBM professional XML Developer<br />SAP certified Development Consultant (NetWeaver portal and Web JavaApplication)
Hi, Lasse, I just tried what you said -> add the xmlns also to the child node, but the excpetion is still like: IOException occur: java.lang.NullPointerException Nothing changed..:-( Roy
SCJP 1.4/SCBCD/SCWCD<br />MCSE<br />IBM professional XML Developer<br />SAP certified Development Consultant (NetWeaver portal and Web JavaApplication)
Hi, Lasse, Sorry, it works, I have made a typing error... Thanks very much, Have a nice day, Roy
SCJP 1.4/SCBCD/SCWCD<br />MCSE<br />IBM professional XML Developer<br />SAP certified Development Consultant (NetWeaver portal and Web JavaApplication)
Lasse, I have one more question, In the first case your describe, suppose I have the XSLT like: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="www.abc.com/xyz"> ... <xsl:template match="my:sdc"/> <xlk version="1.1"> ... </xsl:stylesheet>
actually I want to get the target file like: <xlk version="1.1"> ... </xlk>
but actually I always get <xlk xmlns:my="www.abc.com/xyz" version="1.1"> ... <xlk>
U know I don't need the xmlns from XSLT staying in my target xml file, How can I remove it, what should I set in the XSLT?
Thanks, Roy
SCJP 1.4/SCBCD/SCWCD<br />MCSE<br />IBM professional XML Developer<br />SAP certified Development Consultant (NetWeaver portal and Web JavaApplication)
Find the solution , have to write: <xsl:stylesheet exclude-result-prefixes="my" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="www.sap.com/slim" version="1.0" >
Roy
SCJP 1.4/SCBCD/SCWCD<br />MCSE<br />IBM professional XML Developer<br />SAP certified Development Consultant (NetWeaver portal and Web JavaApplication)
A berm makes a great wind break. And we all like to break wind once in a while. Like this tiny ad:
Gift giving made easy with the permaculture playing cards