You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Omar Hamed <om...@gmail.com> on 2009/11/15 15:10:15 UTC

How to add new node to the document and attach it with its correct PSVI ?

Hi,
       I'm working on a UI application that lets the user edit the xml
document based on the grammar specified in its schema. At first I don't know
how to add a new node using XERCES. Second when I add new node using the
normal DOM APIs, I can't get the schema information (PSVI) so I wanna ask
how to add new node to the document and attach it with its correct PSVI.

I don't know it there are APIs to re-validate the document so that I can
attach new nodes with its PSVI.

Best regards,
Omar Mostafa

Re: How to add new node to the document and attach it with its correct PSVI ?

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
You should be looking at the *source code* of the samples. They're
primarily meant to educate developers on how to use the APIs, not so much
for direct consumption by your application.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Omar Hamed <om...@gmail.com> wrote on 11/18/2009 03:05:38 AM:

> I have been searching the mailing list for the past two days with no
clue.
> Regarding the samples, I don't understand it, like "java
> jaxp.SourceValidator (options) ..." how could I use this in my code ??
>
> Thanks in advance,,
> Omar Hamed

> On Sun, Nov 15, 2009 at 9:50 PM, Michael Glavassevich
<mrglavas@ca.ibm.com
> > wrote:
> Omar Hamed <om...@gmail.com> wrote on 11/15/2009 02:26:24 PM:
>
>
> > The JAXP samples will generate the data access classes and the beans
> > that represent the grammar specified in the XSD, am I right ?
>
>
> No. You must be thinking of *JAXB*. That's something entirely
> different and not supported by Xerces.
>
> Please take a look at the samples and FAQs in the documentation. If
> you're still not sure after reviewing that I suggest that you search
> the mailing list archives [1] where you'll find many past
> discussions on DOM and PSVI.
>
>
> > What I want to do is to get the PSVI dynamically while my
> > application is running.
> >
> > I hope it's clear now.

> Thanks.
>
> [1] http://xerces-j-users.markmail.org/
>
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org

Re: How to add new node to the document and attach it with its correct PSVI ?

Posted by Omar Hamed <om...@gmail.com>.
I have been searching the mailing list for the past two days with no clue.
Regarding the samples, I don't understand it, like "java
jaxp.SourceValidator (options) ..." how could I use this in my code ??

Thanks in advance,
Omar Hamed

On Sun, Nov 15, 2009 at 9:50 PM, Michael Glavassevich
<mr...@ca.ibm.com>wrote:

> Omar Hamed <om...@gmail.com> wrote on 11/15/2009 02:26:24 PM:
>
>
> > The JAXP samples will generate the data access classes and the beans
> > that represent the grammar specified in the XSD, am I right ?
>
>
> No. You must be thinking of *JAXB*. That's something entirely different and
> not supported by Xerces.
>
> Please take a look at the samples and FAQs in the documentation. If you're
> still not sure after reviewing that I suggest that you search the mailing
> list archives [1] where you'll find many past discussions on DOM and PSVI.
>
>
> > What I want to do is to get the PSVI dynamically while my
> > application is running.
> >
> > I hope it's clear now.
>
> Thanks.
>
> [1] http://xerces-j-users.markmail.org/
>
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
>


-- 
0µªΓ

Re: How to add new node to the document and attach it with its correct PSVI ?

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Omar Hamed <om...@gmail.com> wrote on 11/15/2009 02:26:24 PM:

> The JAXP samples will generate the data access classes and the beans
> that represent the grammar specified in the XSD, am I right ?

No. You must be thinking of *JAXB*. That's something entirely different and
not supported by Xerces.

Please take a look at the samples and FAQs in the documentation. If you're
still not sure after reviewing that I suggest that you search the mailing
list archives [1] where you'll find many past discussions on DOM and PSVI.

> What I want to do is to get the PSVI dynamically while my
> application is running.
>
> I hope it's clear now.

Thanks.

[1] http://xerces-j-users.markmail.org/

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Re: How to add new node to the document and attach it with its correct PSVI ?

Posted by Omar Hamed <om...@gmail.com>.
The JAXP samples will generate the data access classes and the beans that
represent the grammar specified in the XSD, am I right ?

What I want to do is to get the PSVI dynamically while my application is
running.

I hope it's clear now.

On Sun, Nov 15, 2009 at 6:15 PM, Michael Glavassevich
<mr...@ca.ibm.com>wrote:

> Omar Hamed <om...@gmail.com> wrote on 11/15/2009 11:08:33 AM:
>
>
> > Thanks Michael for your prompt response.
>
> > But I want to do this in the runtime not using JAXP.
>
> I have no idea what you mean by that.
>
>
> > The typical scenario I want to do is to add a new node at the runtime and
>
> > use its type definition as well.
> >
> > The problem is that the PSVI gets created at the document loading
> > time and I can't create a new ElementPSVI and set the type definition.
>
> You need to re-validate the document and you can do that using JAXP. Take a
> look at the sample.
>
>
> > On Sun, Nov 15, 2009 at 5:36 PM, Michael Glavassevich <
> mrglavas@ca.ibm.com
> > > wrote:
> > Hi Omar,
> >
> > You need to validate the document in order to get PSVI. The
> > jaxp.SourceValidator sample [1] included with Xerces shows how you
> > can validate a DOM using the JAXP Validation API.
> >
> > Thanks.
> >
> > [1] http://xerces.apache.org/xerces2-j/samples-jaxp.html#SourceValidator
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
>


-- 
0µªΓ

Re: How to add new node to the document and attach it with its correct PSVI ?

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Omar Hamed <om...@gmail.com> wrote on 11/15/2009 11:08:33 AM:

> Thanks Michael for your prompt response.
> But I want to do this in the runtime not using JAXP.

I have no idea what you mean by that.

> The typical scenario I want to do is to add a new node at the runtime and
> use its type definition as well.
>
> The problem is that the PSVI gets created at the document loading
> time and I can't create a new ElementPSVI and set the type definition.

You need to re-validate the document and you can do that using JAXP. Take a
look at the sample.

> On Sun, Nov 15, 2009 at 5:36 PM, Michael Glavassevich
<mrglavas@ca.ibm.com
> > wrote:
> Hi Omar,
>
> You need to validate the document in order to get PSVI. The
> jaxp.SourceValidator sample [1] included with Xerces shows how you
> can validate a DOM using the JAXP Validation API.
>
> Thanks.
>
> [1] http://xerces.apache.org/xerces2-j/samples-jaxp.html#SourceValidator
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Re: How to add new node to the document and attach it with its correct PSVI ?

Posted by Omar Hamed <om...@gmail.com>.
Thanks Michael for your prompt response.
But I want to do this in the runtime not using JAXP. The typical scenario I
want to do is to add a new node at the runtime and use its
type definition as well.

The problem is that the PSVI gets created at the document loading time and I
can't create a new ElementPSVI and set the type definition.

On Sun, Nov 15, 2009 at 5:36 PM, Michael Glavassevich
<mr...@ca.ibm.com>wrote:

> Hi Omar,
>
> You need to validate the document in order to get PSVI. The
> jaxp.SourceValidator sample [1] included with Xerces shows how you can
> validate a DOM using the JAXP Validation API.
>
> Thanks.
>
> [1] http://xerces.apache.org/xerces2-j/samples-jaxp.html#SourceValidator
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Omar Hamed <om...@gmail.com> wrote on 11/15/2009 09:10:15 AM:
>
> > Hi,
> >        I'm working on a UI application that lets the user edit the
> > xml document based on the grammar specified in its schema. At first
> > I don't know how to add a new node using XERCES. Second when I add
> > new node using the normal DOM APIs, I can't get the schema
> > information (PSVI) so I wanna ask how to add new node to the
> > document and attach it with its correct PSVI.
> >
> > I don't know it there are APIs to re-validate the document so that I
> > can attach new nodes with its PSVI.
> >
> > Best regards,
> > Omar Mostafa
>
>


-- 
0µªΓ

Re: How to add new node to the document and attach it with its correct PSVI ?

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Omar,

You need to validate the document in order to get PSVI. The
jaxp.SourceValidator sample [1] included with Xerces shows how you can
validate a DOM using the JAXP Validation API.

Thanks.

[1] http://xerces.apache.org/xerces2-j/samples-jaxp.html#SourceValidator

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Omar Hamed <om...@gmail.com> wrote on 11/15/2009 09:10:15 AM:

> Hi,
>        I'm working on a UI application that lets the user edit the
> xml document based on the grammar specified in its schema. At first
> I don't know how to add a new node using XERCES. Second when I add
> new node using the normal DOM APIs, I can't get the schema
> information (PSVI) so I wanna ask how to add new node to the
> document and attach it with its correct PSVI.
>
> I don't know it there are APIs to re-validate the document so that I
> can attach new nodes with its PSVI.
>
> Best regards,
> Omar Mostafa