[jdom-interest] XML type identification

Philip Nelson panmanphil at yahoo.com
Wed Nov 13 15:39:41 PST 2002


Parse the schema *as an xml document*, then find all the element tags in the xs
namespace that you are interested in.  Get the name attribute from those
elements and you will have the element names that you want to search for.

Same basic approach for the element type except your you would add the code to
follow those ref attributes into their actual definition in the schema


--- "Kevin E. Allen" <keallen at mail.stic.net> wrote:
> 
>    This is about a half XML and half JDOM question, but here goes.
> 
> Schema looks about like this:
> 
> <xs:element name="coordParam2D">
>    ... snip ...
> </xs:element>
> 
> <xs:element name="coordParam3D">
>    ... snip ...
> </xs:element>
> 
> <xs:group name="coordVisParams">
>   <xs:choice>
>     <xs:element ref="coordParam2D" />
>     <xs:element ref="coordParam3D" />
>   </xs:choice>
> </xs:group>
> 
> <xs:element name="coordinateGroup">
>   <xs:complexType>
>     <xs:sequence>
>       ... snip ...
>       <xs:group    ref="coordVisParams" minOccurs="1" maxOccurs="unbounded"
> />
>     </xs:sequence>
>   </xs:complexType>
> </xs:element>
> 
>    Now, here's the problem...  I need to be able to extract, for a list,
> all of the elements which fit that 'coordVisParams' element.
> Unfortunately, as near as I've been able to figure out, by the type any
> naming gets to JDOM (or, honestly, anything else for that matter), all I
> have is the actual element name - i.e. coordParam2D or coordParam 3D.
> 
>    Short of hard-coding specific element indexes based on the schema - and
> making the code hideously vulnerable to schema changes - is there any way
> to pull this out?
> 
>    By the same token, is there any way to find out what the type of an
> Element actually is?  If I want to make a dynamic utility which will, for
> instance, create a Map with the element names as keys, and
> appropriately-typed (Double, Integer, etc) value objects, is there any way
> to do it short of trial-and-error parsing?
> 
> Thanks,
> 
> 
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com


__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2



More information about the jdom-interest mailing list