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 govelogo <go...@gmail.com> on 2009/06/29 18:29:11 UTC

Name-value pairs in xml root tag

Hi there,
Is it possible to use JAXP API to retrieve schema and prefix name-value
pairs in the root element tag? for example,

<?xml version="1.0" encoding="UTF-8"?>
<test:inputParameters xsi:type="test:ArrayOfParameterType"
xmlns="http://rules.bellaliant.icn/testing"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cbebi-v1-5="http://ossj.org/xml/Common-CBEBi/v1-5"
xmlns:cbecore-v1-5="http://ossj.org/xml/Common-CBECore/v1-5"
xmlns:cbeproduct-v1-5="http://ossj.org/xml/Common-CBEProduct/v1-5"
xmlns:cbeservice-v1-5="http://ossj.org/xml/Common-CBEService/v1-5"
xmlns:co-v1-5="http://ossj.org/xml/Common/v1-5"
xmlns:om-v1-0="http://ossj.org/xml/OrderManagement/v1-0"
xmlns:test="http://rules.aliant.ca/testing"
/>

I can get _xsi:type="test:ArrayOfParameterType"_ from the input parameter
org.xml.sax.Attributes passed on to startElement() method. But can I get the
rest of the n-v pairs in any of the PSVIProvider or TypeInfoProvider APIs?
(I did a quick search, but could not find one)

thanks,
David

Re: Name-value pairs in xml root tag

Posted by govelogo <go...@gmail.com>.
They are just what I want. Thanks a lot. -david

On Mon, Jun 29, 2009 at 10:40 PM, Michael Glavassevich
<mr...@ca.ibm.com>wrote:

> Namespace declarations are normally reported in SAX through the
> startPrefixMapping() [1] and endPrefixMapping() [2] callbacks.
>
> [1]
> http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ContentHandler.html#startPrefixMapping(java.lang.String,%20java.lang.String)
> [2]
> http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ContentHandler.html#endPrefixMapping(java.lang.String)
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> govelogo <go...@gmail.com> wrote on 06/29/2009 01:39:29 PM:
>
>
> > I used the sample handler in jaxp.TypeInfoWriter. Looks like it
> > should be straight forward; I must have overlooked sth ... Can you
> > just quickly point out which object I should use?
>
> >
> > thanks a lot,
> > David
>
> > On Mon, Jun 29, 2009 at 2:07 PM, <ke...@us.ibm.com> wrote:
> > Those are all namespace declarations. If you register the right SAX
> > handler, you should have no trouble seeing them.
> >
> > ______________________________________
> > "... Three things see no end: A loop with exit code done wrong,
> > A semaphore untested, And the change that comes along. ..."
> >  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
> > http://www.ovff.org/pegasus/songs/threes-rev-11.html)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
>
>

Re: Name-value pairs in xml root tag

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
govelogo <go...@gmail.com> wrote on 07/03/2009 12:39:55 AM:

> Hi Michael,
>
> I thought this would solve my problem. But I run into an order issue.
>
> What I want is to be able to match from a uri to its prefix while
> parsing through an xml. It seems startPrefixMapping() is paired
> with startElement(). So if there is a xsi:type attribute of the
> element pointing to a new type yet been parsed, I won't be able to
> find the prefix in the uri -> prefix hashtable I have been keep tracking.

Um... why not? The startPrefixMapping() calls come first. You should always
have all the information you need to do prefix -> uri mapping on any
startElement()..

> It seems to me that a SAX parser may not work for what I want. Is
> there a sample using a DOM parser to traverse a DOM tree and still
> be able to use JAXP to get TypeInfo and ElementPSVI?

There are plenty of samples, FAQs and articles which show how to use or
talk about how to use these things in isolation, but you'd probably have to
connect the dots yourself.

> thanks a lot,
> David

Thanks.

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

Re: Name-value pairs in xml root tag

Posted by govelogo <go...@gmail.com>.
Hi Michael,
I thought this would solve my problem. But I run into an order issue.

What I want is to be able to match from a uri to its prefix while parsing
through an xml. It seems startPrefixMapping() is paired with startElement().
So if there is a xsi:type attribute of the element pointing to a new type
yet been parsed, I won't be able to find the prefix in the uri -> prefix
hashtable I have been keep tracking.

It seems to me that a SAX parser may not work for what I want. Is there a
sample using a DOM parser to traverse a DOM tree and still be able to use
JAXP to get TypeInfo and ElementPSVI?

thanks a lot,
David


On Mon, Jun 29, 2009 at 10:40 PM, Michael Glavassevich
<mr...@ca.ibm.com>wrote:

> Namespace declarations are normally reported in SAX through the
> startPrefixMapping() [1] and endPrefixMapping() [2] callbacks.
>
> [1]
> http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ContentHandler.html#startPrefixMapping(java.lang.String,%20java.lang.String)
> [2]
> http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ContentHandler.html#endPrefixMapping(java.lang.String)
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> govelogo <go...@gmail.com> wrote on 06/29/2009 01:39:29 PM:
>
>
> > I used the sample handler in jaxp.TypeInfoWriter. Looks like it
> > should be straight forward; I must have overlooked sth ... Can you
> > just quickly point out which object I should use?
>
> >
> > thanks a lot,
> > David
>
> > On Mon, Jun 29, 2009 at 2:07 PM, <ke...@us.ibm.com> wrote:
> > Those are all namespace declarations. If you register the right SAX
> > handler, you should have no trouble seeing them.
> >
> > ______________________________________
> > "... Three things see no end: A loop with exit code done wrong,
> > A semaphore untested, And the change that comes along. ..."
> >  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
> > http://www.ovff.org/pegasus/songs/threes-rev-11.html)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
>
>

Re: Name-value pairs in xml root tag

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Namespace declarations are normally reported in SAX through the
startPrefixMapping() [1] and endPrefixMapping() [2] callbacks.

[1]
http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ContentHandler.html#startPrefixMapping
(java.lang.String,%20java.lang.String)
[2]
http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ContentHandler.html#endPrefixMapping
(java.lang.String)

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

govelogo <go...@gmail.com> wrote on 06/29/2009 01:39:29 PM:

> I used the sample handler in jaxp.TypeInfoWriter. Looks like it
> should be straight forward; I must have overlooked sth ... Can you
> just quickly point out which object I should use?
>
> thanks a lot,
> David

> On Mon, Jun 29, 2009 at 2:07 PM, <ke...@us.ibm.com> wrote:
> Those are all namespace declarations. If you register the right SAX
> handler, you should have no trouble seeing them.
>
> ______________________________________
> "... Three things see no end: A loop with exit code done wrong,
> A semaphore untested, And the change that comes along. ..."
>  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
> http://www.ovff.org/pegasus/songs/threes-rev-11.html)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Re: Name-value pairs in xml root tag

Posted by govelogo <go...@gmail.com>.
I used the sample handler in jaxp.TypeInfoWriter. Looks like it should be
straight forward; I must have overlooked sth ... Can you just quickly point
out which object I should use?
thanks a lot,
David

On Mon, Jun 29, 2009 at 2:07 PM, <ke...@us.ibm.com> wrote:

> Those are all namespace declarations. If you register the right SAX
> handler, you should have no trouble seeing them.
>
> ______________________________________
> "... Three things see no end: A loop with exit code done wrong,
> A semaphore untested, And the change that comes along. ..."
>  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
> http://www.ovff.org/pegasus/songs/threes-rev-11.html)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>

Re: Name-value pairs in xml root tag

Posted by ke...@us.ibm.com.
Those are all namespace declarations. If you register the right SAX 
handler, you should have no trouble seeing them.

______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
http://www.ovff.org/pegasus/songs/threes-rev-11.html)

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