You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Simon Fell <so...@zaks.demon.co.uk> on 2000/07/23 06:22:31 UTC

SAXParser & namespaces

Platform: Xerces-C 1.2.0 on Win32.

Hi,
Given the following XML, how do you access the namespace URI's whilst
doing a SAX parse ?


<foo:first xmlns:foo="urn:one" xmlns:bar="urn:two">
	<bar:second />
</foo>

When my startElement gets called for second, how do i get the URI of
the bar namespace ?


Thanks
Simon

Re: SAXParser & namespaces

Posted by Dean Roddey <dr...@charmedquark.com>.
Andy Heninger will probably respond to you tomorrow and tell you where to
send it. If its non-intrusive to the current code, it should be pretty
easily accepted and checked in.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"You young, and you gotcha health. Whatchoo wanna job fer?"


----- Original Message -----
From: "Simon Fell" <so...@zaks.demon.co.uk>
To: <xe...@xml.apache.org>
Sent: Sunday, July 23, 2000 9:21 PM
Subject: Re: SAXParser & namespaces


> thanks. I have a version of this ready to go, it has the following
> bits
>
> SAX2Parser, inherits from SAXParser for most of its implementation
> Sax2DocumentHandler / Sax2HandlerBase, revised event interfaces +
> empty implementation
> Attributes / VecAttributesImpl, replacement for AttributeList, is used
> in the Sax2DocumentHandler interface.
>
> I Also have a new sample SAX2Print, which can expand the namespace
> prefix's out to the URI's on the output.
>
> This are all new files (bar one change to SAXParser.hpp), how do i get
> this to you in a useful format ?
>
> Cheers
> Simon
>
>
> On Sun, 23 Jul 2000 14:31:47 -0700, in soap you wrote:
>
> >You would do something like this:
> >
> >            fScanner->getValidator()->getURIText(uriId, bufURI);
> >
> >So you ask the scanner, which you have in the parser, to give you the
> >validator, which will take a URI id and fill in an XMLBuffer with the
> >resulting URI text. The uriId is of course driven by the element stack
> >because it depends on where you are in the document tree structure. But,
> >those ids are all stored in a URI string pool in the validator.
> >
> >--------------------------
> >Dean Roddey
> >The CIDLib C++ Frameworks
> >Charmed Quark Software
> >droddey@charmedquark.com
> >http://www.charmedquark.com
> >
> >"You young, and you gotcha health. Whatchoo wanna job fer?"
> >
> >
> >----- Original Message -----
> >From: "Simon Fell" <so...@zaks.demon.co.uk>
> >To: <xe...@xml.apache.org>
> >Sent: Sunday, July 23, 2000 1:55 PM
> >Subject: Re: SAXParser & namespaces
> >
> >
> >> ok, makes sense. I've made a SAX2Parser & Sax2DocumentHandler (based
> >> on the Xerces-J equivalent), and am looking at
> >> SAX2Parser::startElement, which needs to make the call to
> >> Sax2DocuementHandler, fDocHandler->startElement(URI_String, localName,
> >> QName).
> >>
> >> What i can't see is how i get the URI, there's no method on
> >> XMLElementDecl to return the URI (and the docs for
> >> XMLElementDecl::getFullName() indicates it should return
> >> {uri}localname when namespaces are enabled, but it always returns
> >> nsAlias:localName). I do get passed the elemURIId from XMLScanner, but
> >> i can't see what to do with it, it looks like i need to use the ID to
> >> lookup in the XMLScanner::fElemStack, which is private (with no
> >> accessor).
> >> Any idea's ?
> >>
> >> Thanks
> >> Simon
> >>
> >>
> >> On Sat, 22 Jul 2000 22:56:46 -0700, in soap you wrote:
> >>
> >> >Just to implement the new callbacks probably wouldn't be too bad. The
> >parser
> >> >itself is already spitting out what needs to be spit. It would be a
> >matter
> >> >of making a new SAX2 directory (I assume that would be the appropriate
> >> >name), and putting in the new interfaces, then doing a SAX2Parser() in
> >the
> >> >Parsers directory. The new callbacks are pretty similar to the old
ones,
> >> >with just more stuff. I don't think it ended up being a strict
superset
> >or
> >> >anything, so I don't think you could just build it onto the existing
one
> >> >(though I could be wrong since I didn't follow it too strictly.)
> >> >
> >> >--------------------------
> >> >Dean Roddey
> >> >The CIDLib C++ Frameworks
> >> >Charmed Quark Software
> >> >droddey@charmedquark.com
> >> >http://www.charmedquark.com
> >> >
> >> >"You young, and you gotcha health. Whatchoo wanna job fer?"
> >> >
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> >> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> >For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


Re: SAXParser & namespaces

Posted by Simon Fell <so...@zaks.demon.co.uk>.
thanks. I have a version of this ready to go, it has the following
bits

SAX2Parser, inherits from SAXParser for most of its implementation
Sax2DocumentHandler / Sax2HandlerBase, revised event interfaces +
empty implementation
Attributes / VecAttributesImpl, replacement for AttributeList, is used
in the Sax2DocumentHandler interface.

I Also have a new sample SAX2Print, which can expand the namespace
prefix's out to the URI's on the output.

This are all new files (bar one change to SAXParser.hpp), how do i get
this to you in a useful format ?

Cheers
Simon


On Sun, 23 Jul 2000 14:31:47 -0700, in soap you wrote:

>You would do something like this:
>
>            fScanner->getValidator()->getURIText(uriId, bufURI);
>
>So you ask the scanner, which you have in the parser, to give you the
>validator, which will take a URI id and fill in an XMLBuffer with the
>resulting URI text. The uriId is of course driven by the element stack
>because it depends on where you are in the document tree structure. But,
>those ids are all stored in a URI string pool in the validator.
>
>--------------------------
>Dean Roddey
>The CIDLib C++ Frameworks
>Charmed Quark Software
>droddey@charmedquark.com
>http://www.charmedquark.com
>
>"You young, and you gotcha health. Whatchoo wanna job fer?"
>
>
>----- Original Message -----
>From: "Simon Fell" <so...@zaks.demon.co.uk>
>To: <xe...@xml.apache.org>
>Sent: Sunday, July 23, 2000 1:55 PM
>Subject: Re: SAXParser & namespaces
>
>
>> ok, makes sense. I've made a SAX2Parser & Sax2DocumentHandler (based
>> on the Xerces-J equivalent), and am looking at
>> SAX2Parser::startElement, which needs to make the call to
>> Sax2DocuementHandler, fDocHandler->startElement(URI_String, localName,
>> QName).
>>
>> What i can't see is how i get the URI, there's no method on
>> XMLElementDecl to return the URI (and the docs for
>> XMLElementDecl::getFullName() indicates it should return
>> {uri}localname when namespaces are enabled, but it always returns
>> nsAlias:localName). I do get passed the elemURIId from XMLScanner, but
>> i can't see what to do with it, it looks like i need to use the ID to
>> lookup in the XMLScanner::fElemStack, which is private (with no
>> accessor).
>> Any idea's ?
>>
>> Thanks
>> Simon
>>
>>
>> On Sat, 22 Jul 2000 22:56:46 -0700, in soap you wrote:
>>
>> >Just to implement the new callbacks probably wouldn't be too bad. The
>parser
>> >itself is already spitting out what needs to be spit. It would be a
>matter
>> >of making a new SAX2 directory (I assume that would be the appropriate
>> >name), and putting in the new interfaces, then doing a SAX2Parser() in
>the
>> >Parsers directory. The new callbacks are pretty similar to the old ones,
>> >with just more stuff. I don't think it ended up being a strict superset
>or
>> >anything, so I don't think you could just build it onto the existing one
>> >(though I could be wrong since I didn't follow it too strictly.)
>> >
>> >--------------------------
>> >Dean Roddey
>> >The CIDLib C++ Frameworks
>> >Charmed Quark Software
>> >droddey@charmedquark.com
>> >http://www.charmedquark.com
>> >
>> >"You young, and you gotcha health. Whatchoo wanna job fer?"
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: SAXParser & namespaces

Posted by Dean Roddey <dr...@charmedquark.com>.
You would do something like this:

            fScanner->getValidator()->getURIText(uriId, bufURI);

So you ask the scanner, which you have in the parser, to give you the
validator, which will take a URI id and fill in an XMLBuffer with the
resulting URI text. The uriId is of course driven by the element stack
because it depends on where you are in the document tree structure. But,
those ids are all stored in a URI string pool in the validator.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"You young, and you gotcha health. Whatchoo wanna job fer?"


----- Original Message -----
From: "Simon Fell" <so...@zaks.demon.co.uk>
To: <xe...@xml.apache.org>
Sent: Sunday, July 23, 2000 1:55 PM
Subject: Re: SAXParser & namespaces


> ok, makes sense. I've made a SAX2Parser & Sax2DocumentHandler (based
> on the Xerces-J equivalent), and am looking at
> SAX2Parser::startElement, which needs to make the call to
> Sax2DocuementHandler, fDocHandler->startElement(URI_String, localName,
> QName).
>
> What i can't see is how i get the URI, there's no method on
> XMLElementDecl to return the URI (and the docs for
> XMLElementDecl::getFullName() indicates it should return
> {uri}localname when namespaces are enabled, but it always returns
> nsAlias:localName). I do get passed the elemURIId from XMLScanner, but
> i can't see what to do with it, it looks like i need to use the ID to
> lookup in the XMLScanner::fElemStack, which is private (with no
> accessor).
> Any idea's ?
>
> Thanks
> Simon
>
>
> On Sat, 22 Jul 2000 22:56:46 -0700, in soap you wrote:
>
> >Just to implement the new callbacks probably wouldn't be too bad. The
parser
> >itself is already spitting out what needs to be spit. It would be a
matter
> >of making a new SAX2 directory (I assume that would be the appropriate
> >name), and putting in the new interfaces, then doing a SAX2Parser() in
the
> >Parsers directory. The new callbacks are pretty similar to the old ones,
> >with just more stuff. I don't think it ended up being a strict superset
or
> >anything, so I don't think you could just build it onto the existing one
> >(though I could be wrong since I didn't follow it too strictly.)
> >
> >--------------------------
> >Dean Roddey
> >The CIDLib C++ Frameworks
> >Charmed Quark Software
> >droddey@charmedquark.com
> >http://www.charmedquark.com
> >
> >"You young, and you gotcha health. Whatchoo wanna job fer?"
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


Re: SAXParser & namespaces

Posted by Simon Fell <so...@zaks.demon.co.uk>.
ok, makes sense. I've made a SAX2Parser & Sax2DocumentHandler (based
on the Xerces-J equivalent), and am looking at
SAX2Parser::startElement, which needs to make the call to
Sax2DocuementHandler, fDocHandler->startElement(URI_String, localName,
QName).

What i can't see is how i get the URI, there's no method on
XMLElementDecl to return the URI (and the docs for
XMLElementDecl::getFullName() indicates it should return
{uri}localname when namespaces are enabled, but it always returns
nsAlias:localName). I do get passed the elemURIId from XMLScanner, but
i can't see what to do with it, it looks like i need to use the ID to
lookup in the XMLScanner::fElemStack, which is private (with no
accessor).
Any idea's ?

Thanks
Simon


On Sat, 22 Jul 2000 22:56:46 -0700, in soap you wrote:

>Just to implement the new callbacks probably wouldn't be too bad. The parser
>itself is already spitting out what needs to be spit. It would be a matter
>of making a new SAX2 directory (I assume that would be the appropriate
>name), and putting in the new interfaces, then doing a SAX2Parser() in the
>Parsers directory. The new callbacks are pretty similar to the old ones,
>with just more stuff. I don't think it ended up being a strict superset or
>anything, so I don't think you could just build it onto the existing one
>(though I could be wrong since I didn't follow it too strictly.)
>
>--------------------------
>Dean Roddey
>The CIDLib C++ Frameworks
>Charmed Quark Software
>droddey@charmedquark.com
>http://www.charmedquark.com
>
>"You young, and you gotcha health. Whatchoo wanna job fer?"
>
>


Re: SAXParser & namespaces

Posted by Dean Roddey <dr...@charmedquark.com>.
Just to implement the new callbacks probably wouldn't be too bad. The parser
itself is already spitting out what needs to be spit. It would be a matter
of making a new SAX2 directory (I assume that would be the appropriate
name), and putting in the new interfaces, then doing a SAX2Parser() in the
Parsers directory. The new callbacks are pretty similar to the old ones,
with just more stuff. I don't think it ended up being a strict superset or
anything, so I don't think you could just build it onto the existing one
(though I could be wrong since I didn't follow it too strictly.)

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"You young, and you gotcha health. Whatchoo wanna job fer?"


----- Original Message -----
From: "Simon Fell" <so...@zaks.demon.co.uk>
To: <xe...@xml.apache.org>
Sent: Saturday, July 22, 2000 10:12 PM
Subject: Re: SAXParser & namespaces


> thanks, that's what i suspected. Do you have any feel for how much
> work the partial implementation would be ?, i might have a crack at
> it.
>
> Cheers
> Simon
>
> On Sat, 22 Jul 2000 21:36:19 -0700, in soap you wrote:
>
> >Can't do it. The SAX1 standard doesn't support namespaces. The SAX2
version
> >does, but the parser doesn't support it yet. It will be a somewhat
> >non-trivial exercise to implement SAX2 for the C++ parser, and it might
be
> >worth just partially implementing it, mainly the extensions ot the
callbacks
> >that would allow support for namespaces and other things that SAX1
doesn't
> >pass through.
> >
> >--------------------------
> >Dean Roddey
> >The CIDLib C++ Frameworks
> >Charmed Quark Software
> >droddey@charmedquark.com
> >http://www.charmedquark.com
> >
> >"You young, and you gotcha health. Whatchoo wanna job fer?"
> >
> >
> >----- Original Message -----
> >From: "Simon Fell" <so...@zaks.demon.co.uk>
> >To: <xe...@xml.apache.org>
> >Sent: Saturday, July 22, 2000 9:22 PM
> >Subject: SAXParser & namespaces
> >
> >
> >> Platform: Xerces-C 1.2.0 on Win32.
> >>
> >> Hi,
> >> Given the following XML, how do you access the namespace URI's whilst
> >> doing a SAX parse ?
> >>
> >>
> >> <foo:first xmlns:foo="urn:one" xmlns:bar="urn:two">
> >> <bar:second />
> >> </foo>
> >>
> >> When my startElement gets called for second, how do i get the URI of
> >> the bar namespace ?
> >>
> >>
> >> Thanks
> >> Simon
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> >> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> >For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


Re: SAXParser & namespaces

Posted by Simon Fell <so...@zaks.demon.co.uk>.
thanks, that's what i suspected. Do you have any feel for how much
work the partial implementation would be ?, i might have a crack at
it.

Cheers
Simon

On Sat, 22 Jul 2000 21:36:19 -0700, in soap you wrote:

>Can't do it. The SAX1 standard doesn't support namespaces. The SAX2 version
>does, but the parser doesn't support it yet. It will be a somewhat
>non-trivial exercise to implement SAX2 for the C++ parser, and it might be
>worth just partially implementing it, mainly the extensions ot the callbacks
>that would allow support for namespaces and other things that SAX1 doesn't
>pass through.
>
>--------------------------
>Dean Roddey
>The CIDLib C++ Frameworks
>Charmed Quark Software
>droddey@charmedquark.com
>http://www.charmedquark.com
>
>"You young, and you gotcha health. Whatchoo wanna job fer?"
>
>
>----- Original Message -----
>From: "Simon Fell" <so...@zaks.demon.co.uk>
>To: <xe...@xml.apache.org>
>Sent: Saturday, July 22, 2000 9:22 PM
>Subject: SAXParser & namespaces
>
>
>> Platform: Xerces-C 1.2.0 on Win32.
>>
>> Hi,
>> Given the following XML, how do you access the namespace URI's whilst
>> doing a SAX parse ?
>>
>>
>> <foo:first xmlns:foo="urn:one" xmlns:bar="urn:two">
>> <bar:second />
>> </foo>
>>
>> When my startElement gets called for second, how do i get the URI of
>> the bar namespace ?
>>
>>
>> Thanks
>> Simon
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: SAXParser & namespaces

Posted by Dean Roddey <dr...@charmedquark.com>.
Can't do it. The SAX1 standard doesn't support namespaces. The SAX2 version
does, but the parser doesn't support it yet. It will be a somewhat
non-trivial exercise to implement SAX2 for the C++ parser, and it might be
worth just partially implementing it, mainly the extensions ot the callbacks
that would allow support for namespaces and other things that SAX1 doesn't
pass through.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"You young, and you gotcha health. Whatchoo wanna job fer?"


----- Original Message -----
From: "Simon Fell" <so...@zaks.demon.co.uk>
To: <xe...@xml.apache.org>
Sent: Saturday, July 22, 2000 9:22 PM
Subject: SAXParser & namespaces


> Platform: Xerces-C 1.2.0 on Win32.
>
> Hi,
> Given the following XML, how do you access the namespace URI's whilst
> doing a SAX parse ?
>
>
> <foo:first xmlns:foo="urn:one" xmlns:bar="urn:two">
> <bar:second />
> </foo>
>
> When my startElement gets called for second, how do i get the URI of
> the bar namespace ?
>
>
> Thanks
> Simon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>