[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-user
Subject:    RE: Generic mapping method?
From:       "Radu Preotiuc-Pietro" <radup () bea ! com>
Date:       2005-11-17 23:49:06
Message-ID: 4B2B4C417991364996F035E1EE39E2E10294F528 () uskiex01 ! amer ! bea ! com
[Download RAW message or body]

You can achieve things 1) and 2) in your list easily using XmlBeans:
Here are the key APIs:

1) XmlBeans.compileXsd(XmlObject[], SchemaTypeLoader,
XmlOptions):SchemaTypeSystem - compiles a Schema loaded at runtime and
returns a collection of compiled Schema artifacts
2) SchemaTypeSystem.parse(File, SchemaType, XmlOptions):XmlObject -
parses an xml document in the context of the Schema types created in
step 1) the result will be a generic XmlObject of course, but the Schema
Types in the XML tree will be set correctly.

You will need to then do step 3) yourself and do whatever mapping you
need, potentially using statically-bound XmlBeans in the process.

Hope this helps,
Radu

-----Original Message-----
From: Kevin Y. Kim (Lists) [mailto:kykim_lists@mac.com] 
Sent: Monday, November 07, 2005 8:17 AM
To: user@xmlbeans.apache.org
Subject: Generic mapping method?


Hi,

I'm not sure if XMLBeans is the correct tool for this, but I'll ask 
anyway.

I will have a situation where I will not know the schema until runtime.
So I think I need three things:
	1) Ability to create a schema "structure" at runtime.
	2) Use this information to parse the XML file
	3) Store it in a generic hash-table structure.

I believe that my data will end up looking like this:
<Data>
	<metadata>
		<field name="foo" type="xsd:string"/>
		<field name="bar" type="xsd:integer"/>
	</metadata>
	<datum id="1">
		<foo>one</foo>
		<bar>1</bar>
	</datum>
	<datum id="2">
		<foo>two</foo>
		<bar>2</bar>
	</datum>
	...
</Data>

The metadata may exist in another file that has a well defined schema,
if necessary.

What I'd end up with is a list of a hash-table of appropriate XmlObject
subclass (XmlString and XmlInteger in this example).

I know this is not really what XMLBeans was designed to do, but can I 
leverage
the framework to do this for me?

Thanks,
-kevin

		


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic