[OpenSAML] Unmarshalling issue: XML doc with no prefix and no namespace

223 views
Skip to first unread message

KARTHIKEYAN RAMALINGAM

unread,
Mar 31, 2011, 5:46:24 AM3/31/11
to mace-open...@internet2.edu
Hi All,

I am new to OpenSaml and trying to use Open Saml for my project.

Issue in Unmarsahalling:
------------------------------

I am unable to unmarshall the document object if the input well formed xml
document's namespace and prefix is empty.

In my input XML document, the namespace and namespace prefix is not present.
While unmarshalling the document element, I am getting NullPointerException
since the unmarshaller retrieved below is null.

Unmarshaller
unmarshaller=Configuration.getUnmarshallerFactory().getUnmarshaller(el
ement);

But, when I provide the namespace accordingly in the document
and in the code, the unmarshalling works fine. :-)

Per OpenSaml, is it mandatory for an input xml document to have a
valid/non-empty namespace or prefix for successful un-marshalling?

The input xml document is as below:
<?xml version="1.0"
encoding="UTF-8"?><data><parameters><param1>abc</param1><param2>xyz</p
aram2></parameters></data>

Please let me know if I am missing some thing. Your inputs are highly
appreciated. Many Thanks.

Regards,
Karthikeyan.R

Cantor, Scott E.

unread,
Mar 31, 2011, 10:44:57 AM3/31/11
to mace-open...@internet2.edu
On 3/31/11 11:46 AM, "KARTHIKEYAN RAMALINGAM" <krama...@paypal.com>
wrote:

>In my input XML document, the namespace and namespace prefix is not
>present.
>While unmarshalling the document element, I am getting
>NullPointerException
>since the unmarshaller retrieved below is null.

You should always check for null, that's the primary bug.

>Per OpenSaml, is it mandatory for an input xml document to have a
>valid/non-empty namespace or prefix for successful un-marshalling?

You have to have registered classes for the XML you have. Whether it has a
namespace isn't the point, and prefixes have nothing to do with it apart
from how the XML is expressed. From the sound of it, you ought to start by
reading the XML Namespaces spec and/or take a pass over some intro
material on them.

> The input xml document is as below:
> <?xml version="1.0"
> encoding="UTF-8"?><data><parameters><param1>abc</param1><param2>xyz</p
> aram2></parameters></data>

There's not going to be anything in this code base that knows about your
XML. If you really wanted to use these APIs to process it, you'd have to
create implementation, builder, marshaller, and unmarshaller classes for
all your content, or rely on generic classes like XSAny.

-- Scott

Reply all
Reply to author
Forward
0 new messages