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 Michael Glavassevich <mr...@ca.ibm.com> on 2009/05/29 04:25:50 UTC

Re: Loading an XSModel from a DOM Document object

Hello,

(FYI: you should ask usage questions on j-users@xerces.apache.org)

riyer <ri...@esri.com> wrote on 05/28/2009 09:29:47 PM:

> Hello,
>
> I have a couple questions regarding the Xerces XML Schema API.
>
> 1. Is it possible to load/create an XSModel from an existing DOM Document
> object?

Yes, take a look at XMLGrammarPreparser [1]. You can pass it a
DOMInputSource [2] as input. Once you're done loading call toXSModel() on
the XSGrammar.

> 2. If the above is not possible, then is there any way to access the
> underlying Document object from an XSModel? (I am of course assuming that
> the XS implementation internally uses DOM).

No, because the XSModel implementation isn't backed by a DOM. DOM is used
as an intermediate representation in constructing the XSModel but it's
thrown out at the end.

> Any advise is appreciated.
>
> Thanks,
> Ranjit
> --
> View this message in context: http://www.nabble.com/Loading-an-
> XSModel-from-a-DOM-Document-object-tp23772911p23772911.html
> Sent from the Xerces - J - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org

Thanks.

[1] http://xerces.apache.org/xerces2-j/faq-grammars.html#faq-3>
[2]
http://xerces.apache.org/xerces2-j/javadocs/xerces2/org/apache/xerces/util/DOMInputSource.html:

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

Re: Loading an XSModel from a DOM Document object

Posted by riyer <ri...@esri.com>.
That clarifies it. I did think something similar while I was having a shower
this morning; your answer gives it validation now.

Thanks Micheal.

Ranjit


Michael Glavassevich-3 wrote:
> 
> 
> Hi Ranjit,
> 
> riyer <ri...@esri.com> wrote on 05/29/2009 01:42:05 AM:
> 
>> Thanks for the quick response Micheal.
>>
>> Am glad to know that it is possible to construct an XSModel starting from
> a
>> DOM document, but your answer to my second question makes me wonder if
> this
>> is dangerous to do, because you said that the XSModel may choose to throw
>> away the DOM. I would like to start from the DOM document, construct an
>> XSModel and then go back and do a few more things on the same DOM. Can
> you
>> please confirm if this is safe to do?
> 
> The XSModel doesn't throw away the DOM. It never has a reference to it.
> The
> DOM is traversed to construct the XSModel, but once we're done we don't
> need it anymore so we drop all of our references to it. That's what I
> meant
> by throw away. The DOM would normally get garbage collected, but if you
> still have a reference to it you're free to keep using it.
> 
>> Thanks,
>> Ranjit
> 
> Thanks.
> 
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
> 

-- 
View this message in context: http://www.nabble.com/Loading-an-XSModel-from-a-DOM-Document-object-tp23772911p23782626.html
Sent from the Xerces - J - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


Re: Loading an XSModel from a DOM Document object

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

riyer <ri...@esri.com> wrote on 05/29/2009 01:42:05 AM:

> Thanks for the quick response Micheal.
>
> Am glad to know that it is possible to construct an XSModel starting from
a
> DOM document, but your answer to my second question makes me wonder if
this
> is dangerous to do, because you said that the XSModel may choose to throw
> away the DOM. I would like to start from the DOM document, construct an
> XSModel and then go back and do a few more things on the same DOM. Can
you
> please confirm if this is safe to do?

The XSModel doesn't throw away the DOM. It never has a reference to it. The
DOM is traversed to construct the XSModel, but once we're done we don't
need it anymore so we drop all of our references to it. That's what I meant
by throw away. The DOM would normally get garbage collected, but if you
still have a reference to it you're free to keep using it.

> Thanks,
> Ranjit

Thanks.

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

Re: Loading an XSModel from a DOM Document object

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

riyer <ri...@esri.com> wrote on 05/29/2009 01:42:05 AM:

> Thanks for the quick response Micheal.
>
> Am glad to know that it is possible to construct an XSModel starting from
a
> DOM document, but your answer to my second question makes me wonder if
this
> is dangerous to do, because you said that the XSModel may choose to throw
> away the DOM. I would like to start from the DOM document, construct an
> XSModel and then go back and do a few more things on the same DOM. Can
you
> please confirm if this is safe to do?

The XSModel doesn't throw away the DOM. It never has a reference to it. The
DOM is traversed to construct the XSModel, but once we're done we don't
need it anymore so we drop all of our references to it. That's what I meant
by throw away. The DOM would normally get garbage collected, but if you
still have a reference to it you're free to keep using it.

> Thanks,
> Ranjit

Thanks.

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

Re: Loading an XSModel from a DOM Document object

Posted by riyer <ri...@esri.com>.
Thanks for the quick response Micheal. 

Am glad to know that it is possible to construct an XSModel starting from a
DOM document, but your answer to my second question makes me wonder if this
is dangerous to do, because you said that the XSModel may choose to throw
away the DOM. I would like to start from the DOM document, construct an
XSModel and then go back and do a few more things on the same DOM. Can you
please confirm if this is safe to do?

Thanks,
Ranjit


Michael Glavassevich-3 wrote:
> 
> Hello,
> 
> (FYI: you should ask usage questions on j-users@xerces.apache.org)
> 
> riyer <ri...@esri.com> wrote on 05/28/2009 09:29:47 PM:
> 
>> Hello,
>>
>> I have a couple questions regarding the Xerces XML Schema API.
>>
>> 1. Is it possible to load/create an XSModel from an existing DOM Document
>> object?
> 
> Yes, take a look at XMLGrammarPreparser [1]. You can pass it a
> DOMInputSource [2] as input. Once you're done loading call toXSModel() on
> the XSGrammar.
> 
>> 2. If the above is not possible, then is there any way to access the
>> underlying Document object from an XSModel? (I am of course assuming that
>> the XS implementation internally uses DOM).
> 
> No, because the XSModel implementation isn't backed by a DOM. DOM is used
> as an intermediate representation in constructing the XSModel but it's
> thrown out at the end.
> 
>> Any advise is appreciated.
>>
>> Thanks,
>> Ranjit
>> --
>> View this message in context: http://www.nabble.com/Loading-an-
>> XSModel-from-a-DOM-Document-object-tp23772911p23772911.html
>> Sent from the Xerces - J - Dev mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
>> For additional commands, e-mail: j-dev-help@xerces.apache.org
> 
> Thanks.
> 
> [1] http://xerces.apache.org/xerces2-j/faq-grammars.html#faq-3>
> [2]
> http://xerces.apache.org/xerces2-j/javadocs/xerces2/org/apache/xerces/util/DOMInputSource.html:
> 
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
> 

-- 
View this message in context: http://www.nabble.com/Loading-an-XSModel-from-a-DOM-Document-object-tp23772911p23774507.html
Sent from the Xerces - J - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org