File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Using namspaces with x:parse/x:out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using namspaces with x:parse/x:out" Watch "Using namspaces with x:parse/x:out" New topic
Author

Using namspaces with x:parse/x:out

Helmut Lerch
Ranch Hand

Joined: Feb 11, 2001
Posts: 48
Hy all,

I have an xml-file with a namespace declaration. For example:

--file.xml--
<?xml version="1.0"?>
<sn:root xmlns:sn="somenamespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="somenamespace somenamespace.xsd">
<sn:item>Some Text</sn:item>
</sn:root>

How can I parse and access the content of this file with jsp? The following code produces only an output if I omit the xmlns declaration in "file.xml".

--file.jsp---
<c:import url="file.xml" var="xml"/>
<x :parse xml="${xml}" var="doc" />
<x ut select="$doc/root/item" />

Thanks very much for helping,
Helmut
[ November 07, 2004: Message edited by: Helmut Lerch ]
Helmut Lerch
Ranch Hand

Joined: Feb 11, 2001
Posts: 48
After some serching I found the answer on my on:

<c:import url="file.xml" var="xml"/>
<x:parse xml="${xml}" var="doc" />
<xut select="$doc/*[local-name()='root' and namespace-uri()='somenamespace']/*[local-name()='item' and namespace-uri()='somenamespace']" />

Helmut
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using namspaces with x:parse/x:out