|Re: Adding a plain string to an AnyType FeatureMap (for Ed Merks) [message #422708 is a reply to message #422707]
||Sun, 14 September 2008 16:01
| Ed Merks
Registered: July 2009
Shahar Ronen wrote:
> I use a schema containing the following "any" part:
> <xsd:complexType name="xmlDataType">
> <xsd:documentation>A wrapper to contain arbitrary XML content.
> <xsd:any namespace="##any" processContents="lax" maxOccurs=
> I would like to create an EMF model for the schema, in which the part
> listed above consists of arbitrary XML content, passed as a string. I
> don't know (and don't care) what schema this XML content conforms to,
> and therefore I can't (and don't want to) define a schema or an EClass
> for it.
> Is there a way to just paste a given string as an entry on the feature
Not if the string is XML content with attributes and nested elements.
You'd have to parse it first.
> How can this be done?
You'd have to parse the string using an XML resource. A resource as
produced by GenericXMLResourceFactoryImpl should be able to parse
arbitrary XML content. The contents of the resulting resource could
then be moved under your xmlDataType's getAny(). You could use
null) to load from a string, and then get the DocumentRoot out of that
resource, access it's mixed feature to get the feature map entry for the
root element, and add that to the getAny feature map.
> I had a look at "Binding XML to Java", but didn't find a solution
> there (or at least I couldn't recognize one).
> P.S. Ed, I used your tip for the opposite direction (extracting a
> string from AnyType FeatureMap) and seems to work.
Powered by FUDForum
. Page generated in 0.03570 seconds