Home » Modeling » EMF » validating xml file against its schema?
validating xml file against its schema? [message #388329] |
Wed, 06 October 2004 01:38 |
Eclipse User |
|
|
|
Originally posted by: jiehu.ca.ibm.com
Hi,
Does EMF validate the xml file against its schema? I have created an EMF
model for a schema, and want to load an xml file for that schema into the
model. I want the xml file be validated against its schema so that user can
get meaningful error message. Does EMF has this ability? I know JAXB has.
Thanks,
Jie
|
|
| |
Re: validating xml file against its schema? [message #388366 is a reply to message #388335] |
Thu, 07 October 2004 20:44 |
Eclipse User |
|
|
|
Originally posted by: jiehu.ca.ibm.com
Thanks for your answer. But I cannot find XMLResource.OPTION_PARSER_POOL.
I am having a problem with loading the xml file. In the xsd file, I had
element name defined starting with upper case, so does the xml file.
However, when load the xml file, EMF complained that it cannot find the
feature. If I change to lower case in the xml file, then it worked. But the
xml file is not valid for the schema anymore.
For example,
xml file like this won't work.
<BusinessItem id="BI001" name="BI1">
<Description>This is description of BI1</Description>
</BusinessItem>
but change to this worked.
<businessItem id="BI001" name="BI1">
<description>This is description of BI1</description>
</businessItem>
Any idea?
thanks,
Jie
"Ed Merks" <merks@ca.ibm.com> wrote in message
news:ck0jdb$ah4$1@eclipse.org...
> Jie,
>
> You should be sure to look in Resource.getErrors after loading to detect
> basic parser errors, and you can use
> org.eclipse.emf.ecore.util.Diagnostician.INSTANCE.valid(EObj ect) to
> validate a tree of objects against the constraints defined for them at
> any time, including right after loading. It's also possible to use
> XMLResource.OPTION_PARSER_POOL to create a parser that knows about your
> schema and does the normal validation while parsing an instance. This
> will ensure 100% schema validity whereas EMF validation will only
> provide an approximation.
>
>
> Jie Hu wrote:
>
> >Hi,
> >Does EMF validate the xml file against its schema? I have created an EMF
> >model for a schema, and want to load an xml file for that schema into the
> >model. I want the xml file be validated against its schema so that user
can
> >get meaningful error message. Does EMF has this ability? I know JAXB
has.
> >
> >Thanks,
> >
> >Jie
> >
> >
> >
> >
|
|
|
Re: validating xml file against its schema? [message #388367 is a reply to message #388366] |
Thu, 07 October 2004 20:52 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------060904050307020406050508
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Jie,
Typo, I meant OPTION_USE_PARSER_POOL.
It sounds like you aren't using the generated resource factory to create
your resource and hence aren't using option
XMLResource.OPTION_EXTENDED_META_DATA which is needed in order to
respect the original schema's names.
Jie Hu wrote:
>Thanks for your answer. But I cannot find XMLResource.OPTION_PARSER_POOL.
>I am having a problem with loading the xml file. In the xsd file, I had
>element name defined starting with upper case, so does the xml file.
>However, when load the xml file, EMF complained that it cannot find the
>feature. If I change to lower case in the xml file, then it worked. But the
>xml file is not valid for the schema anymore.
>
>For example,
>
>xml file like this won't work.
><BusinessItem id="BI001" name="BI1">
>
><Description>This is description of BI1</Description>
>
></BusinessItem>
>
>but change to this worked.
>
><businessItem id="BI001" name="BI1">
>
><description>This is description of BI1</description>
>
></businessItem>
>
>
>Any idea?
>
>thanks,
>
>Jie
>
>
>"Ed Merks" <merks@ca.ibm.com> wrote in message
>news:ck0jdb$ah4$1@eclipse.org...
>
>
>>Jie,
>>
>>You should be sure to look in Resource.getErrors after loading to detect
>>basic parser errors, and you can use
>> org.eclipse.emf.ecore.util.Diagnostician.INSTANCE.valid(EObj ect) to
>>validate a tree of objects against the constraints defined for them at
>>any time, including right after loading. It's also possible to use
>>XMLResource.OPTION_PARSER_POOL to create a parser that knows about your
>>schema and does the normal validation while parsing an instance. This
>>will ensure 100% schema validity whereas EMF validation will only
>>provide an approximation.
>>
>>
>>Jie Hu wrote:
>>
>>
>>
>>>Hi,
>>>Does EMF validate the xml file against its schema? I have created an EMF
>>>model for a schema, and want to load an xml file for that schema into the
>>>model. I want the xml file be validated against its schema so that user
>>>
>>>
>can
>
>
>>>get meaningful error message. Does EMF has this ability? I know JAXB
>>>
>>>
>has.
>
>
>>>Thanks,
>>>
>>>Jie
>>>
>>>
>>>
>>>
>>>
>>>
>
>
>
>
--------------060904050307020406050508
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Jie,<br>
<br>
Typo, I meant OPTION_USE_PARSER_POOL. <br>
<br>
It sounds like you aren't using the generated resource factory to
create your resource and hence aren't using option
XMLResource.OPTION_EXTENDED_META_DATA which is needed in order to
respect the original schema's names.<br>
<br>
<br>
Jie Hu wrote:
<blockquote cite="midck49j6$92n$1@eclipse.org" type="cite">
<pre wrap="">Thanks for your answer. But I cannot find XMLResource.OPTION_PARSER_POOL.
I am having a problem with loading the xml file. In the xsd file, I had
element name defined starting with upper case, so does the xml file.
However, when load the xml file, EMF complained that it cannot find the
feature. If I change to lower case in the xml file, then it worked. But the
xml file is not valid for the schema anymore.
For example,
xml file like this won't work.
<BusinessItem id="BI001" name="BI1">
<Description>This is description of BI1</Description>
</BusinessItem>
but change to this worked.
<businessItem id="BI001" name="BI1">
<description>This is description of BI1</description>
</businessItem>
Any idea?
thanks,
Jie
"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com"><merks@ca.ibm.com></a> wrote in message
<a class="moz-txt-link-freetext" href="news:ck0jdb$ah4$1@eclipse.org">news:ck0jdb$ah4$1@eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Jie,
You should be sure to look in Resource.getErrors after loading to detect
basic parser errors, and you can use
org.eclipse.emf.ecore.util.Diagnostician.INSTANCE.valid(EObj ect) to
validate a tree of objects against the constraints defined for them at
any time, including right after loading. It's also possible to use
XMLResource.OPTION_PARSER_POOL to create a parser that knows about your
schema and does the normal validation while parsing an instance. This
will ensure 100% schema validity whereas EMF validation will only
provide an approximation.
Jie Hu wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
Does EMF validate the xml file against its schema? I have created an EMF
model for a schema, and want to load an xml file for that schema into the
model. I want the xml file be validated against its schema so that user
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->can
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">get meaningful error message. Does EMF has this ability? I know JAXB
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->has.
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Thanks,
Jie
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>
--------------060904050307020406050508--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: validating xml file against its schema? [message #388643 is a reply to message #388367] |
Sat, 16 October 2004 02:47 |
Eclipse User |
|
|
|
Originally posted by: jiehu.ca.ibm.com
This is a multi-part message in MIME format.
------=_NextPart_000_000C_01C4B308.EC5BB580
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Thanks for your answer. I still cannot found the OPTION_USE_PARSER_POOL. =
Forgot to metion, I am using emf 1.1.1.
For the other schema's name problem, you are correct, I wasn't use the =
generated resource factory. After correct that, it fixed that problem.
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:ck4a09$9s7$1@eclipse.org...
Jie,
Typo, I meant OPTION_USE_PARSER_POOL. =20
It sounds like you aren't using the generated resource factory to =
create your resource and hence aren't using option =
XMLResource.OPTION_EXTENDED_META_DATA which is needed in order to =
respect the original schema's names.
Jie Hu wrote:=20
Thanks for your answer. But I cannot find =
XMLResource.OPTION_PARSER_POOL.
I am having a problem with loading the xml file. In the xsd file, I had
element name defined starting with upper case, so does the xml file.
However, when load the xml file, EMF complained that it cannot find the
feature. If I change to lower case in the xml file, then it worked. But =
the
xml file is not valid for the schema anymore.
For example,
xml file like this won't work.
<BusinessItem id=3D"BI001" name=3D"BI1">
<Description>This is description of BI1</Description>
</BusinessItem>
but change to this worked.
<businessItem id=3D"BI001" name=3D"BI1">
<description>This is description of BI1</description>
</businessItem>
Any idea?
thanks,
Jie
"Ed Merks" <merks@ca.ibm.com> wrote in message
news:ck0jdb$ah4$1@eclipse.org...
Jie,
You should be sure to look in Resource.getErrors after loading to detect
basic parser errors, and you can use
org.eclipse.emf.ecore.util.Diagnostician.INSTANCE.valid(EObj ect) to
validate a tree of objects against the constraints defined for them at
any time, including right after loading. It's also possible to use
XMLResource.OPTION_PARSER_POOL to create a parser that knows about your
schema and does the normal validation while parsing an instance. This
will ensure 100% schema validity whereas EMF validation will only
provide an approximation.
Jie Hu wrote:
Hi,
Does EMF validate the xml file against its schema? I have created an EMF
model for a schema, and want to load an xml file for that schema into =
the
model. I want the xml file be validated against its schema so that user
can
get meaningful error message. Does EMF has this ability? I know JAXB
has.
Thanks,
Jie
=20
=20
------=_NextPart_000_000C_01C4B308.EC5BB580
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2800.1458" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks for your answer. I still cannot =
found the=20
OPTION_USE_PARSER_POOL. Forgot to metion, I am using emf=20
1.1.1.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>For the other schema's name problem, =
you are=20
correct, I wasn't use the generated resource factory. After correct =
that, it=20
fixed that problem.</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" <<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=20
wrote in message <A=20
=
href=3D"news:ck4a09$9s7$1@eclipse.org">news:ck4a09$9s7$1@eclipse.org</A>.=
...</DIV>Jie,<BR><BR>Typo,=20
I meant OPTION_USE_PARSER_POOL. <BR><BR>It sounds like you =
aren't using=20
the generated resource factory to create your resource and hence =
aren't using=20
option XMLResource.OPTION_EXTENDED_META_DATA which is needed in order =
to=20
respect the original schema's names.<BR><BR><BR>Jie Hu wrote:=20
<BLOCKQUOTE cite=3Dmidck49j6$92n$1@eclipse.org type=3D"cite"><PRE =
wrap=3D"">Thanks for your answer. But I cannot find =
XMLResource.OPTION_PARSER_POOL.
I am having a problem with loading the xml file. In the xsd file, I had
element name defined starting with upper case, so does the xml file.
However, when load the xml file, EMF complained that it cannot find the
feature. If I change to lower case in the xml file, then it worked. But =
the
xml file is not valid for the schema anymore.
For example,
xml file like this won't work.
<BusinessItem id=3D"BI001" name=3D"BI1">
<Description>This is description of BI1</Description>
</BusinessItem>
but change to this worked.
<businessItem id=3D"BI001" name=3D"BI1">
<description>This is description of BI1</description>
</businessItem>
Any idea?
thanks,
Jie
"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com"><merks@ca.ibm.com></A> wrote in =
message
<A class=3Dmoz-txt-link-freetext =
href=3D"news:ck0jdb$ah4$1@eclipse.org">news:ck0jdb$ah4$1@eclipse.org</A>.=
...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Jie,
You should be sure to look in Resource.getErrors after loading to detect
basic parser errors, and you can use
org.eclipse.emf.ecore.util.Diagnostician.INSTANCE.valid(EObj ect) to
validate a tree of objects against the constraints defined for them at
any time, including right after loading. It's also possible to use
XMLResource.OPTION_PARSER_POOL to create a parser that knows about your
schema and does the normal validation while parsing an instance. This
will ensure 100% schema validity whereas EMF validation will only
provide an approximation.
Jie Hu wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,
Does EMF validate the xml file against its schema? I have created an EMF
model for a schema, and want to load an xml file for that schema into =
the
model. I want the xml file be validated against its schema so that user
</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->can
</PRE>
<BLOCKQUOTE type=3D"cite">
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">get meaningful error =
message. Does EMF has this ability? I know JAXB
</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->has.
</PRE>
<BLOCKQUOTE type=3D"cite">
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Thanks,
Jie
</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->
</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_000C_01C4B308.EC5BB580--
|
|
|
Re: validating xml file against its schema? [message #388645 is a reply to message #388643] |
Sat, 16 October 2004 11:48 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------000309000905020209080205
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Jie,
Since it was introduced in 2.0.0, that's not surprising.
Jie Hu wrote:
> Thanks for your answer. I still cannot found the
> OPTION_USE_PARSER_POOL. Forgot to metion, I am using emf 1.1.1.
> For the other schema's name problem, you are correct, I wasn't use the
> generated resource factory. After correct that, it fixed that problem.
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:ck4a09$9s7$1@eclipse.org...
> Jie,
>
> Typo, I meant OPTION_USE_PARSER_POOL.
>
> It sounds like you aren't using the generated resource factory to
> create your resource and hence aren't using option
> XMLResource.OPTION_EXTENDED_META_DATA which is needed in order to
> respect the original schema's names.
>
>
> Jie Hu wrote:
>
>>Thanks for your answer. But I cannot find XMLResource.OPTION_PARSER_POOL.
>>I am having a problem with loading the xml file. In the xsd file, I had
>>element name defined starting with upper case, so does the xml file.
>>However, when load the xml file, EMF complained that it cannot find the
>>feature. If I change to lower case in the xml file, then it worked. But the
>>xml file is not valid for the schema anymore.
>>
>>For example,
>>
>>xml file like this won't work.
>><BusinessItem id="BI001" name="BI1">
>>
>><Description>This is description of BI1</Description>
>>
>></BusinessItem>
>>
>>but change to this worked.
>>
>><businessItem id="BI001" name="BI1">
>>
>><description>This is description of BI1</description>
>>
>></businessItem>
>>
>>
>>Any idea?
>>
>>thanks,
>>
>>Jie
>>
>>
>>"Ed Merks" <merks@ca.ibm.com> wrote in message
>>news:ck0jdb$ah4$1@eclipse.org...
>>
>>
>>>Jie,
>>>
>>>You should be sure to look in Resource.getErrors after loading to detect
>>>basic parser errors, and you can use
>>> org.eclipse.emf.ecore.util.Diagnostician.INSTANCE.valid(EObj ect) to
>>>validate a tree of objects against the constraints defined for them at
>>>any time, including right after loading. It's also possible to use
>>>XMLResource.OPTION_PARSER_POOL to create a parser that knows about your
>>>schema and does the normal validation while parsing an instance. This
>>>will ensure 100% schema validity whereas EMF validation will only
>>>provide an approximation.
>>>
>>>
>>>Jie Hu wrote:
>>>
>>>
>>>
>>>>Hi,
>>>>Does EMF validate the xml file against its schema? I have created an EMF
>>>>model for a schema, and want to load an xml file for that schema into the
>>>>model. I want the xml file be validated against its schema so that user
>>>>
>>>>
>>can
>>
>>
>>>>get meaningful error message. Does EMF has this ability? I know JAXB
>>>>
>>>>
>>has.
>>
>>
>>>>Thanks,
>>>>
>>>>Jie
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
>>
>>
>
--------------000309000905020209080205
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Jie,<br>
<br>
Since it was introduced in 2.0.0, that's not surprising.<br>
<br>
<br>
Jie Hu wrote:
<blockquote cite="midckq1pk$pn4$1@eclipse.org" type="cite">
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2800.1458" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Thanks for your answer. I still
cannot found the OPTION_USE_PARSER_POOL. Forgot to metion, I am using
emf 1.1.1.</font></div>
<div><font face="Arial" size="2">For the other schema's name problem,
you are correct, I wasn't use the generated resource factory. After
correct that, it fixed that problem.</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" <<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>>
wrote in message <a href="news:ck4a09$9s7$1@eclipse.org">news:ck4a09$9s7$1@eclipse.org</a>...</div>
Jie,<br>
<br>
Typo, I meant OPTION_USE_PARSER_POOL. <br>
<br>
It sounds like you aren't using the generated resource factory to
create your resource and hence aren't using option
XMLResource.OPTION_EXTENDED_META_DATA which is needed in order to
respect the original schema's names.<br>
<br>
<br>
Jie Hu wrote:
<blockquote cite="midck49j6$92n$1@eclipse.org" type="cite">
<pre wrap="">Thanks for your answer. But I cannot find XMLResource.OPTION_PARSER_POOL.
I am having a problem with loading the xml file. In the xsd file, I had
element name defined starting with upper case, so does the xml file.
However, when load the xml file, EMF complained that it cannot find the
feature. If I change to lower case in the xml file, then it worked. But the
xml file is not valid for the schema anymore.
For example,
xml file like this won't work.
<BusinessItem id="BI001" name="BI1">
<Description>This is description of BI1</Description>
</BusinessItem>
but change to this worked.
<businessItem id="BI001" name="BI1">
<description>This is description of BI1</description>
</businessItem>
Any idea?
thanks,
Jie
"Ed Merks" <a class="moz-txt-link-rfc2396E"
href="mailto:merks@ca.ibm.com"><merks@ca.ibm.com></a> wrote in message
<a class="moz-txt-link-freetext" href="news:ck0jdb$ah4$1@eclipse.org">news:ck0jdb$ah4$1@eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Jie,
You should be sure to look in Resource.getErrors after loading to detect
basic parser errors, and you can use
org.eclipse.emf.ecore.util.Diagnostician.INSTANCE.valid(EObj ect) to
validate a tree of objects against the constraints defined for them at
any time, including right after loading. It's also possible to use
XMLResource.OPTION_PARSER_POOL to create a parser that knows about your
schema and does the normal validation while parsing an instance. This
will ensure 100% schema validity whereas EMF validation will only
provide an approximation.
Jie Hu wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
Does EMF validate the xml file against its schema? I have created an EMF
model for a schema, and want to load an xml file for that schema into the
model. I want the xml file be validated against its schema so that user
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->can
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">get meaningful error message. Does EMF has this ability? I know JAXB
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->has.
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Thanks,
Jie
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>
--------------000309000905020209080205--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Tue Sep 24 22:08:08 GMT 2024
Powered by FUDForum. Page generated in 0.03823 seconds
|