qexo-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qexo-general] namespaces in xquery


From: Víctor Torres Padrosa
Subject: [Qexo-general] namespaces in xquery
Date: Fri, 21 Nov 2003 16:22:58 +0100

Hello,
 
I would be grateful if anyone could help me.
I'm using kawa-1.7.jar and it seems that it does not understand the namespace's declarations.
 
1- Given the following xml file (did.xml):

<?xml version="1.0" encoding="UTF-8"?>

<didl:DIDL>

<r:license xmlns:r="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:sx="urn:mpeg:mpeg21:2003:01-REL-SX-NS" xmlns:mx="urn:mpeg:mpeg21:2003:01-REL-MX-NS" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">......</r:license>

.....

</didl:DIDL>

2- And the following query:

for $c in document("did.xml")
return  $c//*:license

3- I obtain the result:

<r:license>.....</r:license>

This result does not have the namespaces! Does anyone know how to keep them?
I would be also interested in extracting the namespace´s prefixes (r, sx, and mx) given their urn _expression_ (urn:mpeg:mpeg21:2003:01-REL-R-NS, urn:mpeg:mpeg21:2003:01-REL-SX-NS and urn:mpeg:mpeg21:2003:01-REL-MX-NS).
 
The function I'm using to evaluate the query is the following:
 
   public void evalLicenseQuery(String squery){
       XQuery xq=new XQuery();
       Object result=new Object();
  
       try{
            result=xq.eval(squery);
            File outputFile = new File("LicenseFile.xml");
            FileWriter out = new FileWriter(outputFile);
            XMLPrinter xp = new XMLPrinter(out);
            xp.writeObject(result);
            xp.println();
            xp.flush();
            
       }catch(java.lang.Throwable ex){
           System.out.println(ex.toString());
       }
   }
 
Thank you very much for your help!
 
Víctor
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]