Home » Developer & Programmer » JDeveloper, Java & XML » Extracting XML namespaces (11G)
Extracting XML namespaces [message #569283] Wed, 24 October 2012 03:18 Go to next message
Xeres_LT
Messages: 3
Registered: October 2012
Junior Member
I have many XML files with multiple namespaces.
Is where a way to extract all namespaces? This is one of my XMLs

<?xml version="1.0" encoding="UTF-8"?>
<form:Documents xmlns:form="test1" xmlns:addData="test2">
<Paklausimas:_Uzsienio-biuro-paklausimas addData:DocumentState="Correct" addData:ImagePath="C:\Users\Public\Data.pdf" xmlns:Paklausimas="test3">
<_Document_Section_1>
<_dokumento-rusis>Uzsienio-biuro-paklausimas</_dokumento-rusis>
<_dokumento-nr>1109193852</_dokumento-nr>
<_dokumento-data>2012-10-16</_dokumento-data>
<_siuntejas>POLISH MOTOR INSURERS' BUREAU</_siuntejas>
<_eismo-ivykio-data>2004-07-09</_eismo-ivykio-data>
<_eismo-ivykio-valstybe>PL</_eismo-ivykio-valstybe>
<_tp-vum>ABC123</_tp-vum>
<_tp-marke>VW</_tp-marke>
<_tp-modelis>POLO</_tp-modelis>
<_pirminio-dokumento-nr>PL-2871987</_pirminio-dokumento-nr>
<_paketo-nr>123456</_paketo-nr>
<_paketo-vardas>Batch</_paketo-vardas>
</_Document_Section_1>
</_Uzsienio-biuro-paklausimas:_Uzsienio-biuro-paklausimas>
</form:Documents>



Re: Extracting XML namespaces [message #569285 is a reply to message #569283] Wed, 24 October 2012 04:23 Go to previous messageGo to next message
muralikri
Messages: 638
Registered: August 2011
Location: chennai
Senior Member

it is not valid xml try like..

select xmltype(xmldata) from dual 
Re: Extracting XML namespaces [message #569286 is a reply to message #569285] Wed, 24 October 2012 04:55 Go to previous messageGo to next message
Xeres_LT
Messages: 3
Registered: October 2012
Junior Member
Sorry, I was simplifying XML missed something, now it should work

<?xml version="1.0" encoding="UTF-8"?>
<form:Documents xmlns:form="test1" xmlns:addData="test2">
<Paklausimas:_Uzsienio-biuro-paklausimas addData:DocumentState="Correct" addData:ImagePath="C:\Users\Public\Data.pdf" xmlns:Paklausimas="test3">
<_Document_Section_1>
<_dokumento-rusis>Uzsienio-biuro-paklausimas</_dokumento-rusis>
<_dokumento-nr>1109193852</_dokumento-nr>
<_dokumento-data>2012-10-16</_dokumento-data>
<_siuntejas>POLISH MOTOR INSURERS BUREAU</_siuntejas>
<_eismo-ivykio-data>2004-07-09</_eismo-ivykio-data>
<_eismo-ivykio-valstybe>PL</_eismo-ivykio-valstybe>
<_tp-vum>ABC123</_tp-vum>
<_tp-marke>VW</_tp-marke>
<_tp-modelis>POLO</_tp-modelis>
<_pirminio-dokumento-nr>PL-2871987</_pirminio-dokumento-nr>
<_paketo-nr>123456</_paketo-nr>
<_paketo-vardas>Batch</_paketo-vardas>
</_Document_Section_1>
</Paklausimas:_Uzsienio-biuro-paklausimas>
</form:Documents>
Re: Extracting XML namespaces [message #569287 is a reply to message #569286] Wed, 24 October 2012 05:42 Go to previous messageGo to next message
muralikri
Messages: 638
Registered: August 2011
Location: chennai
Senior Member

Can you post output? within code tages
Re: Extracting XML namespaces [message #569288 is a reply to message #569283] Wed, 24 October 2012 06:24 Go to previous messageGo to next message
Michel Cadot
Messages: 59814
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Unfortunatly Oracle function returns only the top-most namespace and even then only the first one (at least in 10.2 I work):
SQL> with data as ( select
  2  '<?xml version="1.0" encoding="UTF-8"?>
  3  <form:Documents xmlns:form="test1" xmlns:addData="test2">
  4  <Paklausimas:_Uzsienio-biuro-paklausimas addData:DocumentState="Correct" 
  5    addData:ImagePath="C:\Users\Public\Data.pdf" xmlns:Paklausimas="test3">
  6  <_Document_Section_1>
  7  <_dokumento-rusis>Uzsienio-biuro-paklausimas</_dokumento-rusis>
  8  <_dokumento-nr>1109193852</_dokumento-nr>
  9  <_dokumento-data>2012-10-16</_dokumento-data>
 10  <_siuntejas>POLISH MOTOR INSURERS BUREAU</_siuntejas>
 11  <_eismo-ivykio-data>2004-07-09</_eismo-ivykio-data>
 12  <_eismo-ivykio-valstybe>PL</_eismo-ivykio-valstybe>
 13  <_tp-vum>ABC123</_tp-vum>
 14  <_tp-marke>VW</_tp-marke>
 15  <_tp-modelis>POLO</_tp-modelis>
 16  <_pirminio-dokumento-nr>PL-2871987</_pirminio-dokumento-nr>
 17  <_paketo-nr>123456</_paketo-nr>
 18  <_paketo-vardas>Batch</_paketo-vardas>
 19  </_Document_Section_1>
 20  </Paklausimas:_Uzsienio-biuro-paklausimas>
 21  </form:Documents>' val from dual )
 22  select xmltype(val).getNamespace() from data
 23  /
XMLTYPE(VAL).GETNAMESPACE()
-------------------------------------------------------------------------------
test1

Regards
Michel
Re: Extracting XML namespaces [message #569289 is a reply to message #569288] Wed, 24 October 2012 07:52 Go to previous messageGo to next message
muralikri
Messages: 638
Registered: August 2011
Location: chennai
Senior Member

We can do it unix script..if yes please post your output you want?
Re: Extracting XML namespaces [message #569296 is a reply to message #569289] Wed, 24 October 2012 08:16 Go to previous message
Xeres_LT
Messages: 3
Registered: October 2012
Junior Member
I decided to make a configuration table with namespaces where product creator's would specify what namespaces are used i think it would be easier.
Previous Topic: loadjava error
Next Topic: Create a Databound Hierarchy Viewer
Goto Forum:
  


Current Time: Thu Nov 27 23:47:30 CST 2014

Total time taken to generate the page: 0.12458 seconds