xerces-j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brent.john...@homepoint.com
Subject RE: Child Nodes/Elements
Date Wed, 04 Oct 2000 14:57:54 GMT

Well - yes that would see to be whats happening (as I mentioned at the end
of my last email).  But that doesnt seem to be what SHOULD be happening
though.
It would seem to me that by parsing the instance document against a schema
which says that an element's content is "elementOnly" - then there should
not be any text type nodes within that element.

- Brent



                                                                                         
                                                    
                    Oscar Lantz                                                          
                                                    
                    <oscar@razorf        To:     "'xerces-j-dev@xml.apache.org'" <xerces-j-dev@xml.apache.org>
                               
                    ish.com>             cc:     (bcc: Brent Johnson/HPC)             
                                                       
                                         Subject:     RE: Child Nodes/Elements           
                                                    
                    10/04/00                                                             
                                                    
                    10:45 AM                                                             
                                                    
                    Please                                                               
                                                    
                    respond to                                                           
                                                    
                    xerces-j-dev                                                         
                                                    
                                                                                         
                                                    
                                                                                         
                                                    



I guess you itearte over elements and then try to iterate over the child
nodes of every element. It would seem obvious that the child nodes probably
aren't elements but perhaps text and entity nodes.

/oscar lantz

> -----Original Message-----
> From: brent.johnson@homepoint.com [mailto:brent.johnson@homepoint.com]
> Sent: Wednesday, October 04, 2000 4:38 PM
> To: xerces-j-dev@xml.apache.org
> Subject: Child Nodes/Elements
>
>
> I'm scanning XML documents as they come through looking for
> specific tags.
> But, I get the following error when I try to read the tag
> name for a child
> element:
> java.lang.ClassCastException: org.apache.xerces.dom.TextImpl
>
> Here is an example of what the instance doc looks like:
> <txEvent>
>     <PartyAlignment>
>         ....
>     </PartyAlignment>
> </txEvent>
> <txEvent>
>     <Order>
>         ....
>     </Order>
> </txEvent>
> <txEvent>
>     <Order>
>         ...
>     </Order>
> </txEvent>
>
> Here is the code that's causing it:
> NodeList nodes = xmldoc.getElementsByTagName("txEvent");
> int nsize = nodes.getLength();
> String message = "";
> for(int i = 0; i < nsize; i++) {
>     Element txevent = (Element) nodes.item(i);
>     if (txevent.hasChildNodes()) {
>         Element child = (Element) txevent.getFirstChild(); //
> <------------- Casting getFirstChild() is failing
>         message += "Element: " + child.getTagName() + "\n";
>     }
> }
> reply.generateContent(XMLReply.REPLY_WRN_DEBUG, message +
> "Total txEvents
> Matched: " + totalEvents);
>
> The "txEvent" tags are defined as being elementOnly in the
> schema - but it
> appears as though the first child returned is some text information or
> something else?
>
> Any ideas?  Thanks,
>
> - Brent
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>

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






Mime
View raw message