XML reader: problems with default namespace

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

XML reader: problems with default namespace

Andrea Nascetti
Dear all,

I am writing an XML reader to read the metadata associated with SAR images (e.g. TerraSAR-X and Radarsat-2) and extract the information necessary to orthorectify the images. Now, I have some problems to parse and perform queries on an XML file using the Opticks XMLreader class. In more details, I noticed that the problem is related to the default namespace declared in the root tag of the XML. An example follows:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<product xmlns="http://www.rsi.ca/rs2/prod/xml/schemas" copyright="RADARSAT-2 Data and Products (c) MacDonald, Dettwiler and Associates Ltd., 2008 - All Rights Reserved." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.rsi.ca/rs2/prod/xml/schemas schemas/rs2prod_product.xsd">


If I erase the namespace declaration (i.e. xmlns="http://www.rsi.ca/rs2/prod/xml/schemas") from the file, my code is working well and I easily parse the file with the query method.

Do you know how to configure the XML Opticks parser to account for the namespace?
I thank you very much in advance for all suggestions you might provide.

Kind regards,
Andrea Nascetti
Reply | Threaded
Open this post in threaded view
|

Re: XML reader: problems with default namespace

dadkins
Administrator
For anyone wondering about the outcome, this issue was discussed in IRC
in #opticks [1][2].

Thanks,
Dustan

[1] http://opticks.org/irclogs/%23opticks/%23opticks.2012-06-04-Mon.txt
[2] http://opticks.org/irclogs/%23opticks/%23opticks.2012-06-05-Tue.txt


-----Original Message-----
From: Andrea Nascetti [mailto:[hidden email]]
Sent: Monday, June 04, 2012 10:20 AM
To: [hidden email]
Subject: [Opticks-devs] XML reader: problems with default namespace

Dear all,

I am writing an XML reader to read the metadata associated with SAR
images
(e.g. TerraSAR-X and Radarsat-2) and extract the information necessary
to
orthorectify the images. Now, I have some problems to parse and perform
queries on an XML file using the Opticks XMLreader class. In more
details, I
noticed that the problem is related to the default namespace declared in
the
root tag of the XML. An example follows:

/<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<product xmlns="http://www.rsi.ca/rs2/prod/xml/schemas"
copyright="RADARSAT-2 Data and Products (c) MacDonald, Dettwiler and
Associates Ltd., 2008 - All Rights Reserved."
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.rsi.ca/rs2/prod/xml/schemas
schemas/rs2prod_product.xsd">/

If I erase the namespace declaration (i.e.
xmlns="http://www.rsi.ca/rs2/prod/xml/schemas") from the file, my code
is
working well and I easily parse the file with the query method.

Do you know how to configure the XML Opticks parser to account for the
namespace?
I thank you very much in advance for all suggestions you might provide.

Kind regards,
Andrea Nascetti

--
View this message in context:
http://opticks-devs.2021163.n4.nabble.com/XML-reader-problems-with-defau
lt-namespace-tp4652676.html
Sent from the opticks-devs mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs



This message and any enclosures are intended only for the addressee.  Please

notify the sender by email if you are not the intended recipient.  If you are

not the intended recipient, you may not use, copy, disclose, or distribute this

message or its contents or enclosures to any other person and any such actions

may be unlawful.  Ball reserves the right to monitor and review all messages

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs
Reply | Threaded
Open this post in threaded view
|

Re: XML reader: problems with default namespace

Andrea Nascetti
Dear all,

I would like to report to the community the solution I adopted to solve the problem in reading XML files (e.g. Radarsat2 XML files) that have a namespace which is different from the standard ones defined in Opticks.

I learned (thanks to hints from Trevor Clarke) that the Opticks XML files have an associated XSD and XML namespace and that the the XmlReader class is designed to load these files. Therefore, there is no way to specify a different namespace for a file (the opticks namespace and a few common xsd namespaces are hard coded into the class).

To overcome this problem I modified the Xmlreader class  (originally defined in the file xmlreader.cpp) and I defined a new xmlreaderSAR class. This new class has, together with the methods of the original class, a new method that is called queryNamespace (you can find the complete method definition in the xmlreaderSAR.cpp file in my git repository https://github.com/GSoC-2012-Nascetti/GSoC_SARPlugIn_Nascetti) and that is appointed to add a default namespace to the list of those supported by Opticks (using the addNamespaceBinding method).

This workaround allowed me to read both the XML files of the SAR satellites I am working with in my current GSOC2012 project (i.e. Terrasar-X, which has not a default namespace declaration, and Radarsat2, which has one) using the same class (i.e. xmlReaderSar). In addition, it is flexible and, in principle, permits to use the class to read any other XML default namespace.

I hope my explanation was not too confused and, to conclude, I would like to thank all the Opticks members that helped me in finding out this workaround.

I hope all the community will benefit from this message.

Kind regards,
Andrea Nascetti
Reply | Threaded
Open this post in threaded view
|

Re: XML reader: problems with default namespace

dadkins
Administrator
Good solution. Thanks for keeping everyone updated.


-----Original Message-----
From: Andrea Nascetti [mailto:[hidden email]]
Sent: Thursday, June 07, 2012 5:36 AM
To: [hidden email]
Subject: Re: [Opticks-devs] XML reader: problems with default namespace

Dear all,

I would like to report to the community the solution I adopted to solve
the
problem in reading XML files (e.g. Radarsat2 XML files) that have a
namespace which is different from the standard ones defined in Opticks.

I learned (thanks to hints from Trevor Clarke) that the Opticks XML
files
have an associated XSD and XML namespace and that the the XmlReader
class is
designed to load these files. Therefore, there is no way to specify a
different namespace for a file (the opticks namespace and a few common
xsd
namespaces are hard coded into the class).

To overcome this problem I modified the Xmlreader class  (originally
defined
in the file xmlreader.cpp) and I defined a new xmlreaderSAR class. This
new
class has, together with the methods of the original class, a new method
that is called queryNamespace (you can find the complete method
definition
in the xmlreaderSAR.cpp file in my git repository
https://github.com/GSoC-2012-Nascetti/GSoC_SARPlugIn_Nascetti
https://github.com/GSoC-2012-Nascetti/GSoC_SARPlugIn_Nascetti ) and that
is
appointed to add a default namespace to the list of those supported by
Opticks (using the addNamespaceBinding method).

This workaround allowed me to read both the XML files of the SAR
satellites
I am working with in my current GSOC2012 project (i.e. Terrasar-X, which
has
not a default namespace declaration, and Radarsat2, which has one) using
the
same class (i.e. xmlReaderSar). In addition, it is flexible and, in
principle, permits to use the class to read any other XML default
namespace.

I hope my explanation was not too confused and, to conclude, I would
like to
thank all the Opticks members that helped me in finding out this
workaround.

I hope all the community will benefit from this message.

Kind regards,
Andrea Nascetti

--
View this message in context:
http://opticks-devs.2021163.n4.nabble.com/XML-reader-problems-with-defau
lt-namespace-tp4652676p4652678.html
Sent from the opticks-devs mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond.
Discussions
will include endpoint security, mobile security and the latest in
malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs



This message and any enclosures are intended only for the addressee.  Please

notify the sender by email if you are not the intended recipient.  If you are

not the intended recipient, you may not use, copy, disclose, or distribute this

message or its contents or enclosures to any other person and any such actions

may be unlawful.  Ball reserves the right to monitor and review all messages

and enclosures sent to or from this email address.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs