• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using namspaces with x:parse/x:out

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After some serching I found the answer on my on:

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

Helmut
 
reply
    Bookmark Topic Watch Topic
  • New Topic