SV: [jdom-interest] Re: Problem extracting include elements from an XML schema.
pernorrman at telia.com
Sun Aug 17 15:59:03 PDT 2003
Your code works for me, with your schema file. However, when I copied
the code snippet, the quotation marks in "includes" turned out to be
the opening/closing quotation marks, whereas the quotation marks in the
XML portion was just single. Maybe this is because of your or mine editor
mail program, but check for hidden characters in the "include" string.
We are developing a tool for a bioinformatics system that allows the user to
interact directly with XML schemas. My code loads a schema and creates a
JDOM tree just as if it were a normal XML document. However, here's the
problem: I'm trying to get the include child elements from the root element
but always the list I'm returned is empty. Checking using the NetBeans
debugger shows that the JDOM Document object matches the underlying schema.
Right, so here's my code:
Document schema = . // This code gets the schema from wherever it happens
to be and
// gives it to JDOM
Element root = schema.getRootElement();
Namespace ns = root.getNamespace();
List includes = root.getChildren( "include", ns );
The List in the last line of code is always empty, this is even the case
when I don't specify the namespace. But when I use the debugger it clearly
shows that the namespace of the root element is the same as that of the
child elements, including the include elements. Does anybody have any idea
what I'm doing wrong? I'm using a test schema from the Ordinance Survey in
the UK, which is as follows:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jdom-interest