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 Mike Hepple <mi...@impresariostudios.com> on 2009/02/19 01:00:45 UTC
Parsing problem
Hi,
I'm using a DOMParser in a custom RSS-reading application. I'm having
a problem with this snippet of XML (extraneous info removed):
<title>...</title>
<guid isPermaLink="true">...</guid>
<link>...</link>
<comments>...</comments>
<description>
...
</description>
<report:id>...</report:id>
<report:category>...</report:category>
<report:attributes>
<report:attribute type="Source">TV Cap</report:attribute>
<report:attribute type="Source">HDTV</report:attribute>
<report:attribute type="Video Fmt">x264</report:attribute>
<report:attribute type="Video Fmt">720p</report:attribute>
<report:attribute type="Video Genre">Action/Adv</report:attribute>
<report:attribute type="Video Genre">Drama</report:attribute>
<report:attribute type="Language">English</report:attribute>
</report:attributes>
<report:groups>
<report:group>...</report:group>
</report:groups>
<report:progress value="1">...</report:progress>
<report:moreinfo>...</report:moreinfo>
The "report:attributes" node is returning as having 0 children, as
this debug output shows:
Element: title
Character data: ...
Element: guid
Attribute: isPermaLink = true
Character data: ...
Element: link
Character data: ...
Element: comments
Character data: ...
Element: description
Element: report:id
Character data: ...
Element: report:category
Character data: ...
Element: report:attributes
Element: report:groups
Element: report:group
Character data: ...
I'm getting the Document through the following code:
DOMParser parser = new DOMParser();
InputStream in;
try {
in = url.openStream();
InputSource source = new InputSource(in);
parser.parse(source);
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Document doc = parser.getDocument();
Is this a bug, or is there something I need to do to get it to work?
I'm on XercesJ 2.9.0 (standard plugin that distributes with eclipse,
I'm using RCP.)
Many thanks in advance for any ideas,
Mike
--
----------------------------------------------
Mike Hepple
mike@impresariostudios.com
----------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Parsing problem
Posted by Mike Hepple <mi...@impresariostudios.com>.
Many thanks - I created a standalone application with the RSS url
hardcoded and it worked, looked at the code in my app and found it
wasn't passing the URL correctly, so I only received a subset of the
feed.
It's amazing what 24 hours can do for your patience :-)
Mike Hepple
On Thu, Feb 19, 2009 at 2:34 PM, <ke...@us.ibm.com> wrote:
>
>> <report:attributes>
>> <report:attribute type="Source">TV Cap</report:attribute>
>> <report:attribute type="Source">HDTV</report:attribute>
>> <report:attribute type="Video Fmt">x264</report:attribute>
>> <report:attribute type="Video Fmt">720p</report:attribute>
>> <report:attribute type="Video
>> Genre">Action/Adv</report:attribute>
>> <report:attribute type="Video Genre">Drama</report:attribute>
>> <report:attribute type="Language">English</report:attribute>
>> </report:attributes>
>>
>> The "report:attributes" node is returning as having 0 children, as
>> this debug output shows:
>
> Hard to believe, since this sort of bug should be detected and corrected
> immediately during pre-release testing.
>
> So as a first step, I'd suggest modifying your code so it captures and/or
> prints out the incoming stream, so you can check that you are receiving the
> document you think you are. (Use a tee filter, or copy the stream into a
> file and parse it back in from there.)
>
> Another obvious question is whether there's another (empty)
> report:attributes element elsewhere in the document, and you're looking at
> that rather than this.
>
> Or there might be a flaw in your DOM-accessing code, which you didn't show
> us. Generally, it's a good idea to work up a small stand-alone example which
> demonstrates the problem -- that gives us something we can usefully debug,
> and if there is a problem in your code it often becomes much easier to see
> when isolated.
--
----------------------------------------------
Mike Hepple
mike@impresariostudios.com
----------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Parsing problem
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
keshlam@us.ibm.com wrote on 02/19/2009 09:34:36 AM:
>
> > <report:attributes>
> > <report:attribute type="Source">TV Cap</report:attribute>
> > <report:attribute type="Source">HDTV</report:attribute>
> > <report:attribute type="Video Fmt">x264</report:attribute>
> > <report:attribute type="Video Fmt">720p</report:attribute>
> > <report:attribute type="Video
> Genre">Action/Adv</report:attribute>
> > <report:attribute type="Video
Genre">Drama</report:attribute>
> > <report:attribute
type="Language">English</report:attribute>
> > </report:attributes>
> >
> > The "report:attributes" node is returning as having 0 children, as
> > this debug output shows:
>
> Hard to believe, since this sort of bug should be detected and
> corrected immediately during pre-release testing.
... and would have likely been reported several times now if this did
escape into the release. When we've goofed on something so basic in the
past (and it's been a long time since that's happened) we usually hear
about it [1] early and often.
> So as a first step, I'd suggest modifying your code so it captures
> and/or prints out the incoming stream, so you can check that you are
> receiving the document you think you are. (Use a tee filter, or copy
> the stream into a file and parse it back in from there.)
>
> Another obvious question is whether there's another (empty) report:
> attributes element elsewhere in the document, and you're looking at
> that rather than this.
>
> Or there might be a flaw in your DOM-accessing code, which you
> didn't show us. Generally, it's a good idea to work up a small
> stand-alone example which demonstrates the problem -- that gives us
> something we can usefully debug, and if there is a problem in your
> code it often becomes much easier to see when isolated.
[1] http://issues.apache.org/jira/browse/XERCESJ-581
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
Re: Parsing problem
Posted by ke...@us.ibm.com.
> <report:attributes>
> <report:attribute type="Source">TV Cap</report:attribute>
> <report:attribute type="Source">HDTV</report:attribute>
> <report:attribute type="Video Fmt">x264</report:attribute>
> <report:attribute type="Video Fmt">720p</report:attribute>
> <report:attribute type="Video
Genre">Action/Adv</report:attribute>
> <report:attribute type="Video
Genre">Drama</report:attribute>
> <report:attribute type="Language">English</report:attribute>
> </report:attributes>
>
> The "report:attributes" node is returning as having 0 children, as
> this debug output shows:
Hard to believe, since this sort of bug should be detected and corrected
immediately during pre-release testing.
So as a first step, I'd suggest modifying your code so it captures and/or
prints out the incoming stream, so you can check that you are receiving
the document you think you are. (Use a tee filter, or copy the stream into
a file and parse it back in from there.)
Another obvious question is whether there's another (empty)
report:attributes element elsewhere in the document, and you're looking at
that rather than this.
Or there might be a flaw in your DOM-accessing code, which you didn't show
us. Generally, it's a good idea to work up a small stand-alone example
which demonstrates the problem -- that gives us something we can usefully
debug, and if there is a problem in your code it often becomes much easier
to see when isolated.