Home » Archived » XML Schema Definition (XSD) » Reading, editing and storing XML file
Reading, editing and storing XML file [message #72912] |
Tue, 07 August 2007 22:52  |
Eclipse User |
|
|
|
Hello everyone!
I try to create some editors for XML files based on XML Schema.
Currently i using JAXB for reading and storing data. This is great tool
- i can read and store data in three lines.. but there is small problem.
For example - i reading by JAXB structure:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="urn:foo:bar">
<element
attribute="before" />
</root>
After storing i'll got:
<?xml version="1.0" encoding="UTF-8"?><root xmlns="urn:foo:bar"><element
attribute="after" /></root>
I can set property for formating etc, but that's not end. JAXB generate
namespace prefixes - so if i want save other namespaces prefixes (before
common, validation etc, after ns1, ns2 and so on) i must create own
NamespacePrefixMapper who will read prefixes from file and give it for
JAXB. I don't want fight with JAXB but everything is going to this -
i'll write prostheses.
And the point of my question - is there any way to read, edit and store
XML without problems JAXB-like problems? I mean - read to objects (i
don't need SAX or DOM-like functionality), edit (setting objects
properties) objects and store only changed attributes [for example given
above]:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="urn:foo:bar">
<element
attribute="after change" />
</root>
I've UI created by eclipse forms and next editors also will have UI
based on forms. Example editor:
http://img.wklej.org/v.php?id=76022agavi%20module%20editor.P NG
Does EMF can do this?
Regards,
Luke
|
|
|
Re: Reading, editing and storing XML file [message #72930 is a reply to message #72912] |
Wed, 08 August 2007 10:25  |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------000904040106030009060204
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: 7bit
Luke,
You'll probably find this information useful:
Binding XML to Java
< http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>
Except for complex types with mixed content, EMF will generally format
the result as well. By default it will be an indented format, but you
can turn that off to have more like the first version without any
unnecessary white space.
For an XML Schema based model, the root of your resource will consists
of a DocumentRoot instance that will have a getXMLNSPrefix map which you
can populate direct with any xmlns declarations you might like to see.
Follow these tutorial steps for your schema to give it a try:
Tutorial: Generating an EMF Model using XML Schema
< http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/tutorials/xlibmod/xlibm od.html>
An editor is generated as well, but we won't be supporting forms
generation until the current release. If you invoke Generate Test Code,
you'll get a *.tests project with JUnit tests as well as an
XyzExample.java that shows how to read and write instances stand alone.
The only tool that I know of that's capable of preserving your exact
formatting (even DOM won't do that) is the structured text (XML) editor
in the web tools project, but it's just an enhanced DOM, so that might
not meet your needs either.
Lukasz Dywicki wrote:
> Hello everyone!
>
> I try to create some editors for XML files based on XML Schema.
> Currently i using JAXB for reading and storing data. This is great
> tool - i can read and store data in three lines.. but there is small
> problem.
>
> For example - i reading by JAXB structure:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlns="urn:foo:bar">
> <element
> attribute="before" />
> </root>
>
> After storing i'll got:
> <?xml version="1.0" encoding="UTF-8"?><root
> xmlns="urn:foo:bar"><element attribute="after" /></root>
>
> I can set property for formating etc, but that's not end. JAXB
> generate namespace prefixes - so if i want save other namespaces
> prefixes (before common, validation etc, after ns1, ns2 and so on) i
> must create own NamespacePrefixMapper who will read prefixes from file
> and give it for JAXB. I don't want fight with JAXB but everything is
> going to this - i'll write prostheses.
>
> And the point of my question - is there any way to read, edit and
> store XML without problems JAXB-like problems? I mean - read to
> objects (i don't need SAX or DOM-like functionality), edit (setting
> objects properties) objects and store only changed attributes [for
> example given above]:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlns="urn:foo:bar">
> <element
> attribute="after change" />
> </root>
>
> I've UI created by eclipse forms and next editors also will have UI
> based on forms. Example editor:
> http://img.wklej.org/v.php?id=76022agavi%20module%20editor.P NG
>
> Does EMF can do this?
>
> Regards,
> Luke
--------------000904040106030009060204
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-2" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Luke,<br>
<br>
You'll probably find this information useful:<br>
<blockquote><a target="_out"
href=" http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava">Binding
XML to Java</a><br>
</blockquote>
Except for complex types with mixed content, EMF will generally format
the result as well.
|
|
|
Re: Reading, editing and storing XML file [message #602571 is a reply to message #72912] |
Wed, 08 August 2007 10:25  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------000904040106030009060204
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: 7bit
Luke,
You'll probably find this information useful:
Binding XML to Java
< http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>
Except for complex types with mixed content, EMF will generally format
the result as well. By default it will be an indented format, but you
can turn that off to have more like the first version without any
unnecessary white space.
For an XML Schema based model, the root of your resource will consists
of a DocumentRoot instance that will have a getXMLNSPrefix map which you
can populate direct with any xmlns declarations you might like to see.
Follow these tutorial steps for your schema to give it a try:
Tutorial: Generating an EMF Model using XML Schema
< http://dev.eclipse.org/viewcvs/indextools.cgi/*checkout*/org .eclipse.emf/doc/org.eclipse.emf.doc/tutorials/xlibmod/xlibm od.html>
An editor is generated as well, but we won't be supporting forms
generation until the current release. If you invoke Generate Test Code,
you'll get a *.tests project with JUnit tests as well as an
XyzExample.java that shows how to read and write instances stand alone.
The only tool that I know of that's capable of preserving your exact
formatting (even DOM won't do that) is the structured text (XML) editor
in the web tools project, but it's just an enhanced DOM, so that might
not meet your needs either.
Lukasz Dywicki wrote:
> Hello everyone!
>
> I try to create some editors for XML files based on XML Schema.
> Currently i using JAXB for reading and storing data. This is great
> tool - i can read and store data in three lines.. but there is small
> problem.
>
> For example - i reading by JAXB structure:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlns="urn:foo:bar">
> <element
> attribute="before" />
> </root>
>
> After storing i'll got:
> <?xml version="1.0" encoding="UTF-8"?><root
> xmlns="urn:foo:bar"><element attribute="after" /></root>
>
> I can set property for formating etc, but that's not end. JAXB
> generate namespace prefixes - so if i want save other namespaces
> prefixes (before common, validation etc, after ns1, ns2 and so on) i
> must create own NamespacePrefixMapper who will read prefixes from file
> and give it for JAXB. I don't want fight with JAXB but everything is
> going to this - i'll write prostheses.
>
> And the point of my question - is there any way to read, edit and
> store XML without problems JAXB-like problems? I mean - read to
> objects (i don't need SAX or DOM-like functionality), edit (setting
> objects properties) objects and store only changed attributes [for
> example given above]:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlns="urn:foo:bar">
> <element
> attribute="after change" />
> </root>
>
> I've UI created by eclipse forms and next editors also will have UI
> based on forms. Example editor:
> http://img.wklej.org/v.php?id=76022agavi%20module%20editor.P NG
>
> Does EMF can do this?
>
> Regards,
> Luke
--------------000904040106030009060204
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-2" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Luke,<br>
<br>
You'll probably find this information useful:<br>
<blockquote><a target="_out"
href=" http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava">Binding
XML to Java</a><br>
</blockquote>
Except for complex types with mixed content, EMF will generally format
the result as well.
|
|
|
Goto Forum:
Current Time: Tue Feb 11 06:44:57 GMT 2025
Powered by FUDForum. Page generated in 0.23984 seconds
|