Skip to main content



      Home
Home » Modeling » EMF » Adding a plain string to an AnyType FeatureMap (for Ed Merks)
Adding a plain string to an AnyType FeatureMap (for Ed Merks) [message #422707] Sun, 14 September 2008 11:11 Go to next message
Eclipse UserFriend
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?
How can this be done?
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.
Re: Adding a plain string to an AnyType FeatureMap (for Ed Merks) [message #422708 is a reply to message #422707] Sun, 14 September 2008 12:01 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Nested Objects to list Object..
Next Topic:XSD Schema + Multiple Root Elements + EMF Editor leads to invalid XML file
Goto Forum:
  


Current Time: Sun Jul 27 09:58:27 EDT 2025

Powered by FUDForum. Page generated in 0.03316 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top