i am a bit hasty, so i could use some help. i made the changes but
still the getElementById is NULL :(

----------------CODE-------------------------
XercesDOMParser* parser = new XercesDOMParser();
    parser->setValidationScheme(XercesDOMParser::Val_Always);
    parser->setValidationSchemaFullChecking(true);
    parser->setDoNamespaces(true);    // optional
    parser->setDoSchema(true);

    ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
    parser->setErrorHandler(errHandler);

    char* xmlFile = "test.xml";

    try
    {
        parser->parse(xmlFile);
        cout<<parser->getDocument()->getElementById(
XMLString::transcode("one"))<<endl;
       .......
------------------XSD-----------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
targetNamespace="http://www.w3schools.com";
xmlns="http://www.w3schools.com"; elementFormDefault="unqualified">
<xs:element name="AnElement">
 <xs:complexType>
   <xs:attribute name="xml:id" type="xs:ID" use="required"/>
 </xs:complexType>
</xs:element>
</xs:schema>

----------------XML---------
<?xml version="1.0" encoding="UTF-8"?>
<Server xmlns="http://www.w3schools.com";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.w3schools.com rules.xsd" >
    <AnElement xml:id="one" >
        <data>dfdfd</data>
        <value>dfdfd</value>
</AnElement>
</Server>
-------------------------

what am i doing wrong now?

On Mon, Dec 15, 2008 at 2:00 AM, David Bertoni <dbert...@apache.org> wrote:
> Suneel Suresh wrote:
>>
>> Code below returns null
>> DOMElement *domElement = parserDom->getDocument()->getElementById(
>> XMLString::transcode("75"));
>>
>> parserDom is initialized as
>>   parserDom = new XercesDOMParser();
>>    parserDom->setValidationScheme(XercesDOMParser::Val_Always);
>>    parserDom->setDoNamespaces(false);
>>
>>  //parserDom->setExternalSchemaLocation("http://www.w3schools.comrules.xsd";);
>>    parserDom->setDoSchema(true);
>>    parserDom->setValidationSchemaFullChecking(true);
>> -------------------------------------------------
>> xml snippet below
>> ......
>> <Server xmlns="http://www.w3schools.com";
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
>> http://www.w3schools.com rules.xsd">
>> <AnElement id="75">
>> </Server>
>
> "75" is not a valid ID in XML, because IDs must match the NCName grammar
> production:
>
> http://www.w3.org/TR/xmlschema-2/#NCName
>
>
>> ----------------------------------
>> The xsd
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; targetNamespace="
>> http://www.w3schools.com"; xmlns="http://www.w3schools.com";
>> elementFormDefault="unqualified">
>> <xs:element name="AnElement ">
>>  <xs:complexType>
>>   <xs:attribute name="id" type="xs:NMTOKEN" use="required"/>
>>  </xs:complexType>
>> </xs:element>
>> </xs:schema>
>> ----------------------------------
>>
>> i am using vc9 on winxp, with xerces-c-3.0.0-x86-windows-vc-9.0
>> Its really getting on my nerves why this simple api call is not working.
>> added to that the xerces tutorials are non existent.
>
> There are many books and tutorials for XML available, so there's no need for
> a Xerces-specific tutorial to explain how ID attributes work in XML.
>
> Just giving an attribute the name "id" is not enough to make it an ID:
>
> http://www.w3.org/TR/xmlschema-2/#ID
>
> If you were to actually declare the attribute as type ID, you would get a
> validation error:
>
> <xs:element name="AnElement">
>  <xs:complexType>
>    <xs:attribute name="id" type="xs:ID" use="required"/>
>  </xs:complexType>
> </xs:element>
>
>> Can anyone shine a light in this tunnel?
>
> You can help save your nerves by understanding the technology you're using.
>
> Dave
>

Reply via email to