Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsXML and XSD models from string
https://www.eclipse.org/forums/index.php/mv/msg/23312/75146/#msg_75146
I have my XML and XSDs in DB columns (as strings/text fields).
What is the fastest and best way (regarding memory and performance) to
load the files to ecore models without storing them in a file?
thanks a lot,
André]]>Andre Ribeiro2008-08-04T17:27:55-00:00Re: XML and XSD models from string
https://www.eclipse.org/forums/index.php/mv/msg/23312/603193/#msg_603193
XMLResource and XSDResourceImpl both support load from a SAX
InputSource. A more generic way is to create a resource and x and call
x.load(new URIConverter.ReadableInputStream(<xmlStringOrReader>, null).
The underlying implementations of XSDResourceImpl and XMLResourceImpl
will unwrap the InputStream and access the string or reader directly,
thereby avoiding the String -> bytes -> String cost.
André Ribeiro wrote:
> Hi,
>
> I have my XML and XSDs in DB columns (as strings/text fields).
> What is the fastest and best way (regarding memory and performance) to
> load the files to ecore models without storing them in a file?
>
> thanks a lot,
> André]]>Ed Merks2008-08-04T18:42:18-00:00Re: XML and XSD models from string
https://www.eclipse.org/forums/index.php/mv/msg/23312/75163/#msg_75163
XMLResource and XSDResourceImpl both support load from a SAX
InputSource. A more generic way is to create a resource and x and call
x.load(new URIConverter.ReadableInputStream(<xmlStringOrReader>, null).
The underlying implementations of XSDResourceImpl and XMLResourceImpl
will unwrap the InputStream and access the string or reader directly,
thereby avoiding the String -> bytes -> String cost.
André Ribeiro wrote:
> Hi,
>
> I have my XML and XSDs in DB columns (as strings/text fields).
> What is the fastest and best way (regarding memory and performance) to
> load the files to ecore models without storing them in a file?
>
> thanks a lot,
> André]]>Ed Merks2008-08-04T18:42:18-00:00Re: XML and XSD models from string
https://www.eclipse.org/forums/index.php/mv/msg/23312/603214/#msg_603214
im using the following lines now:
XMLResource x = new XMLResourceImpl();
x.load(new URIConverter.ReadableInputStream(cf.getFileContent()), null);
i just dont get how can i then have (/create) an object (Eobject ?)
that keeps my XML contents and has the model that it validates against?!
To create the model i am trying to use the XSDEcoreBuilder like
XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
xsdEcoreBuilder.generate(schema);
but since there isnt much (java)docs for these parts i dont know exactly
what this is supposed to do.
My objective is to have an object Model (as the class in OOP) built from
an XSD and the object (as the object in OOP) that is the XML file.
Then i should be able to validate my object against my model.
Is this possible?
Cheers,
André
Ed Merks wrote:
> André,
>
> XMLResource and XSDResourceImpl both support load from a SAX
> InputSource. A more generic way is to create a resource and x and
> call x.load(new URIConverter.ReadableInputStream(<xmlStringOrReader>,
> null). The underlying implementations of XSDResourceImpl and
> XMLResourceImpl will unwrap the InputStream and access the string or
> reader directly, thereby avoiding the String -> bytes -> String cost.
>
>
> André Ribeiro wrote:
>> Hi,
>>
>> I have my XML and XSDs in DB columns (as strings/text fields).
>> What is the fastest and best way (regarding memory and performance)
>> to load the files to ecore models without storing them in a file?
>>
>> thanks a lot,
>> André]]>Andre Ribeiro2008-08-05T14:20:59-00:00Re: XML and XSD models from string
https://www.eclipse.org/forums/index.php/mv/msg/23312/75251/#msg_75251
im using the following lines now:
XMLResource x = new XMLResourceImpl();
x.load(new URIConverter.ReadableInputStream(cf.getFileContent()), null);
i just dont get how can i then have (/create) an object (Eobject ?)
that keeps my XML contents and has the model that it validates against?!
To create the model i am trying to use the XSDEcoreBuilder like
XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
xsdEcoreBuilder.generate(schema);
but since there isnt much (java)docs for these parts i dont know exactly
what this is supposed to do.
My objective is to have an object Model (as the class in OOP) built from
an XSD and the object (as the object in OOP) that is the XML file.
Then i should be able to validate my object against my model.
Is this possible?
Cheers,
André
Ed Merks wrote:
> André,
>
> XMLResource and XSDResourceImpl both support load from a SAX
> InputSource. A more generic way is to create a resource and x and
> call x.load(new URIConverter.ReadableInputStream(<xmlStringOrReader>,
> null). The underlying implementations of XSDResourceImpl and
> XMLResourceImpl will unwrap the InputStream and access the string or
> reader directly, thereby avoiding the String -> bytes -> String cost.
>
>
> André Ribeiro wrote:
>> Hi,
>>
>> I have my XML and XSDs in DB columns (as strings/text fields).
>> What is the fastest and best way (regarding memory and performance)
>> to load the files to ecore models without storing them in a file?
>>
>> thanks a lot,
>> André]]>Andre Ribeiro2008-08-05T14:20:59-00:00Re: XML and XSD models from string
https://www.eclipse.org/forums/index.php/mv/msg/23312/75268/#msg_75268
Comments below.
André Ribeiro wrote:
> Thanks Ed!
>
> im using the following lines now:
> XMLResource x = new XMLResourceImpl();
> x.load(new URIConverter.ReadableInputStream(cf.getFileContent()),
> null);
>
> i just dont get how can i then have (/create) an object (Eobject ?)
> that keeps my XML contents and has the model that it validates against?!
>
> To create the model i am trying to use the XSDEcoreBuilder like
> XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
> XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
> xsdEcoreBuilder.generate(schema);
>
> but since there isnt much (java)docs for these parts i dont know
> exactly what this is supposed to do.
I would suggest starting with the library tutorial and generating the
model for the schema you have. Also invoke Generate Test Code and look
at the generated XyzExample.java. This will give you a better starting
point that what you have now. For example, you'll see that it's
important generally to use a resource set and to register a resource
factory.
>
> My objective is to have an object Model (as the class in OOP) built
> from an XSD and the object (as the object in OOP) that is the XML file.
> Then i should be able to validate my object against my model.
>
> Is this possible?
Yes, but you're doing everything the hardest way possible. I'd suggest
reading http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava
and following http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html
for your schema.
>
> Cheers,
> André
>
>
>
> Ed Merks wrote:
>> André,
>>
>> XMLResource and XSDResourceImpl both support load from a SAX
>> InputSource. A more generic way is to create a resource and x and
>> call x.load(new URIConverter.ReadableInputStream(<xmlStringOrReader>,
>> null). The underlying implementations of XSDResourceImpl and
>> XMLResourceImpl will unwrap the InputStream and access the string or
>> reader directly, thereby avoiding the String -> bytes -> String cost.
>>
>>
>> André Ribeiro wrote:
>>> Hi,
>>>
>>> I have my XML and XSDs in DB columns (as strings/text fields).
>>> What is the fastest and best way (regarding memory and performance)
>>> to load the files to ecore models without storing them in a file?
>>>
>>> thanks a lot,
>>> André]]>Ed Merks2008-08-05T16:17:54-00:00Re: XML and XSD models from string
https://www.eclipse.org/forums/index.php/mv/msg/23312/603219/#msg_603219
Comments below.
André Ribeiro wrote:
> Thanks Ed!
>
> im using the following lines now:
> XMLResource x = new XMLResourceImpl();
> x.load(new URIConverter.ReadableInputStream(cf.getFileContent()),
> null);
>
> i just dont get how can i then have (/create) an object (Eobject ?)
> that keeps my XML contents and has the model that it validates against?!
>
> To create the model i am trying to use the XSDEcoreBuilder like
> XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
> XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
> xsdEcoreBuilder.generate(schema);
>
> but since there isnt much (java)docs for these parts i dont know
> exactly what this is supposed to do.
I would suggest starting with the library tutorial and generating the
model for the schema you have. Also invoke Generate Test Code and look
at the generated XyzExample.java. This will give you a better starting
point that what you have now. For example, you'll see that it's
important generally to use a resource set and to register a resource
factory.
>
> My objective is to have an object Model (as the class in OOP) built
> from an XSD and the object (as the object in OOP) that is the XML file.
> Then i should be able to validate my object against my model.
>
> Is this possible?
Yes, but you're doing everything the hardest way possible. I'd suggest
reading http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava
and following http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html
for your schema.
>
> Cheers,
> André
>
>
>
> Ed Merks wrote:
>> André,
>>
>> XMLResource and XSDResourceImpl both support load from a SAX
>> InputSource. A more generic way is to create a resource and x and
>> call x.load(new URIConverter.ReadableInputStream(<xmlStringOrReader>,
>> null). The underlying implementations of XSDResourceImpl and
>> XMLResourceImpl will unwrap the InputStream and access the string or
>> reader directly, thereby avoiding the String -> bytes -> String cost.
>>
>>
>> André Ribeiro wrote:
>>> Hi,
>>>
>>> I have my XML and XSDs in DB columns (as strings/text fields).
>>> What is the fastest and best way (regarding memory and performance)
>>> to load the files to ecore models without storing them in a file?
>>>
>>> thanks a lot,
>>> André]]>Ed Merks2008-08-05T16:17:54-00:00Re: XML and XSD models from string
https://www.eclipse.org/forums/index.php/mv/msg/23312/75286/#msg_75286
will read them carefully.
cheers,
André
Ed Merks wrote:
> André,
>
> Comments below.
>
> André Ribeiro wrote:
>> Thanks Ed!
>>
>> im using the following lines now:
>> XMLResource x = new XMLResourceImpl();
>> x.load(new URIConverter.ReadableInputStream(cf.getFileContent()),
>> null);
>>
>> i just dont get how can i then have (/create) an object (Eobject ?)
>> that keeps my XML contents and has the model that it validates against?!
>>
>> To create the model i am trying to use the XSDEcoreBuilder like
>> XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
>> XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
>> xsdEcoreBuilder.generate(schema);
>>
>> but since there isnt much (java)docs for these parts i dont know
>> exactly what this is supposed to do.
> I would suggest starting with the library tutorial and generating the
> model for the schema you have. Also invoke Generate Test Code and look
> at the generated XyzExample.java. This will give you a better
> starting point that what you have now. For example, you'll see that
> it's important generally to use a resource set and to register a
> resource factory.
>>
>> My objective is to have an object Model (as the class in OOP) built
>> from an XSD and the object (as the object in OOP) that is the XML file.
>> Then i should be able to validate my object against my model.
>>
>> Is this possible?
> Yes, but you're doing everything the hardest way possible. I'd
> suggest reading
> http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava
> and following
> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html
> for your schema.
>>
>> Cheers,
>> André
>>
>>
>>
>> Ed Merks wrote:
>>> André,
>>>
>>> XMLResource and XSDResourceImpl both support load from a SAX
>>> InputSource. A more generic way is to create a resource and x and
>>> call x.load(new
>>> URIConverter.ReadableInputStream(<xmlStringOrReader>, null). The
>>> underlying implementations of XSDResourceImpl and XMLResourceImpl
>>> will unwrap the InputStream and access the string or reader
>>> directly, thereby avoiding the String -> bytes -> String cost.
>>>
>>>
>>> André Ribeiro wrote:
>>>> Hi,
>>>>
>>>> I have my XML and XSDs in DB columns (as strings/text fields).
>>>> What is the fastest and best way (regarding memory and performance)
>>>> to load the files to ecore models without storing them in a file?
>>>>
>>>> thanks a lot,
>>>> André]]>Andre Ribeiro2008-08-05T18:03:50-00:00Re: XML and XSD models from string
https://www.eclipse.org/forums/index.php/mv/msg/23312/603224/#msg_603224
will read them carefully.
cheers,
André
Ed Merks wrote:
> André,
>
> Comments below.
>
> André Ribeiro wrote:
>> Thanks Ed!
>>
>> im using the following lines now:
>> XMLResource x = new XMLResourceImpl();
>> x.load(new URIConverter.ReadableInputStream(cf.getFileContent()),
>> null);
>>
>> i just dont get how can i then have (/create) an object (Eobject ?)
>> that keeps my XML contents and has the model that it validates against?!
>>
>> To create the model i am trying to use the XSDEcoreBuilder like
>> XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
>> XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
>> xsdEcoreBuilder.generate(schema);
>>
>> but since there isnt much (java)docs for these parts i dont know
>> exactly what this is supposed to do.
> I would suggest starting with the library tutorial and generating the
> model for the schema you have. Also invoke Generate Test Code and look
> at the generated XyzExample.java. This will give you a better
> starting point that what you have now. For example, you'll see that
> it's important generally to use a resource set and to register a
> resource factory.
>>
>> My objective is to have an object Model (as the class in OOP) built
>> from an XSD and the object (as the object in OOP) that is the XML file.
>> Then i should be able to validate my object against my model.
>>
>> Is this possible?
> Yes, but you're doing everything the hardest way possible. I'd
> suggest reading
> http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava
> and following
> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html
> for your schema.
>>
>> Cheers,
>> André
>>
>>
>>
>> Ed Merks wrote:
>>> André,
>>>
>>> XMLResource and XSDResourceImpl both support load from a SAX
>>> InputSource. A more generic way is to create a resource and x and
>>> call x.load(new
>>> URIConverter.ReadableInputStream(<xmlStringOrReader>, null). The
>>> underlying implementations of XSDResourceImpl and XMLResourceImpl
>>> will unwrap the InputStream and access the string or reader
>>> directly, thereby avoiding the String -> bytes -> String cost.
>>>
>>>
>>> André Ribeiro wrote:
>>>> Hi,
>>>>
>>>> I have my XML and XSDs in DB columns (as strings/text fields).
>>>> What is the fastest and best way (regarding memory and performance)
>>>> to load the files to ecore models without storing them in a file?
>>>>
>>>> thanks a lot,
>>>> André]]>Andre Ribeiro2008-08-05T18:03:50-00:00