I'm not particularly familiar with XML Schemas, but I don't think they
provide any way for an XML processor to recognize ID attributes.  Simply
naming them "id" is not sufficient.  You may need a DTD as well.

> -----Original Message-----
> From: Mirko Braun [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 11, 2003 4:49 AM
> To: [EMAIL PROTECTED]
> Subject: problem with getElementById()
> 
> 
> 
>  Hi to all,
> 
>  i,m using the Xerces 2.3.0 to parse an XML-Document 
> validating against a
> Schema.
>  When using the method getElementById() to get a node 
> referenced by an IDREF
> (see code below)
>  a NULL-Pointer is given back. I'm sure that the ID is unique 
> within the XML
> Document.
> 
>  Is their any special feature i have to set according to the 
> use of Schema
> and Xerces?
> 
>  Can anybody help me? Thanks in advance.
> 
>  Mirko
> 
> 
> 
> 
> 
> C++ code:
> 
>       xercesc::DOMNode* pToDOMNode = oRevision.GetDOMNode();
> 
>       xercesc::DOMNamedNodeMap* pToAttr = pToDOMNode->getAttributes();
> 
>       xercesc::DOMNode* pToAuthorRef =
> pToAttr->getNamedItem(xercesc::XMLString::transcode("AuthorRef"));
> 
>       xercesc::DOMDocument* pToDocument = 
> pToAuthorRef->getOwnerDocument();
> 
>       xercesc::DOMElement* pToAuthor =
> pToDocument->getElementById(pToAuthorRef->getNodeValue());
> 
> 
> XML Document:
> 
>       ...
>       <AUTHOR id='_1'>
>               <SHORTNAME>Rz</SHORTNAME>
>               ...
>       </AUTHOR>
>       ...
>       <REVISION AuthorRef='_1'>
>               ...
>       </REVISION>
> 
> 
> 
> 
> XML Schema:
> 
>       <xs:element name="AUTHOR">
>               <xs:complexType>
>                       <xs:sequence>
>                               <xs:element ref="SHORTNAME"/>
>                               ...
>                       </xs:sequence>
>                       <xs:attribute name="id" type="xs:ID" 
> use="required"/>
>               </xs:complexType>
>       </xs:element>
>       ...
>       <xs:element name="REVISION">
>               <xs:complexType>
>                       <xs:sequence>
>                       ...
>                       </xs:sequence>
>                       <xs:attribute name="AuthorRef" 
> type="xs:IDREF" use="required"/>
>               </xs:complexType>
>       </xs:element>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to