File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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:

<?xml version="1.0"?>
<sn:root xmlns:sn="somenamespace"
xsi:schemaLocation="somenamespace somenamespace.xsd">
<sn:item>Some Text</sn:item>

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".

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

Thanks very much for helping,
[ 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']" />

I agree. Here's the link:
subject: Using namspaces with x:parse/x:out
It's not a secret anymore!