|
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 Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Shahar,
Comments below.
Shahar Ronen wrote:
> Hello,
>
> I use a schema containing the following "any" part:
>
> <xsd:complexType name="xmlDataType">
> <xsd:annotation>
> <xsd:documentation>A wrapper to contain arbitrary XML content.
> </xsd:documentation>
> </xsd:annotation>
> <xsd:sequence>
> <xsd:any namespace="##any" processContents="lax" maxOccurs=
> "unbounded"/>
> </xsd:sequence>
> </xsd:complexType>
>
> 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
> map?
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
resource.load(new URIConverter.ReadableInputStream(<some-xml-string>),
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).
>
> Thanks,
> Shahar.
>
> P.S. Ed, I used your tip for the opposite direction (extracting a
> string from AnyType FeatureMap) and seems to work.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03449 seconds