[jdom-interest] Problem with namespace prefixes

Per Spilling Per.Spilling at objectware.no
Sat Jan 27 03:15:55 PST 2001


Hi,

I have recently started to use JDOM to implement a Java/XML databinding
module to be used to implement ebXML-like messaging functionality for a
J2EE framework. This databinding module is based on the articles written
by Brett McLaughlin on this subject.

Currently I'm struggling somewhat to handle namespaces when
unmarshalling an XML instance document. Here is a small example of what
it can look like:

------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<KWS02 
  xmlns="http://www.kbank.no/xml/1.0/kws02" 
  xmlns:xsd="http://www.w3.org/1999/XMLSchema" 
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
  xmlns:cbktypes="http://www.kbank.no/xml/1.0/cbktypes" 
  xsi:schemaLocation="http://www.kbank.no/xml/1.0/kws02 
  kws02.xsd
  http://www.kbank.no/xml/1.0/cbktypes
  CbkTypes.xsd">

  <msgHeader xsi:type="cbktypes:MessageHeader">
  ...
------------------

In this case I need to find the namespace for the 'cbktypes' prefix
given in the 'msgHeader' element, and I therefore try to use 
  Namespace.getNamespace(String prefix, Element context)
to do this.

This method recurses up to the root element, but then it turns out that
it cannot find any of the the 'xmlns:...' attributes, even though they
are declared in the XML instance messages. 

Is this a bug in JDOM or are namespace prefixes not yet implemented?
Any suggestions how I can work around this problem?

-Per

--
Per Spilling, <per.spilling at objectware.no>
Principal consultant, Objectware AS.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20010127/69fc08e0/attachment.htm


More information about the jdom-interest mailing list