CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    21

    Xerces C++ schema parsing

    I am parsing a complex schema using Xerces C++. I need to read the "fixed" values of attribute declarations within element declarations.

    For example:

    <xsd:element name="SampleElement">
    <xsd:complexType>
    <xsd:complexContent>
    <xsd:extension base="SampleElementType">
    <xsd:attribute name="sampleName" type="xsd:string" fixed="XXXXXXXXXX">
    </xsd:attribute>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>
    </xsd:element>

    In this schema exerpt, I would need to read the value "XXXXXXXXXX" from the attribute declaration "sampleName". I have been able to get as far as reading the element declaration into an object of type XSElementDeclaration, and from there I am able to read the attribute declaration into an object of type XSAttributeDeclaration. However, I have not been able to find a method to return the value of the fixed content of the attribute declaration.

    A small snipet of my code:

    XSAttributeDeclaration *xsAttributeDeclaration;

    .
    .
    .

    //After reading the attribute declaration into the xsAttributeDeclaration variable
    CString csFixedValue = xsAttributeDeclaration->getConstraintValue();

    The "getConstraintValue()" method is returning an empty string when I thought it should be returning the value of the fixed constraint.

    The question:

    Am I using the "getConstraintValue()" method improperly, or is it the wrong method to be using altogether? If it is the wrong method, how can I get the "fixed" value from the attribute declaration using an object of type XSAttributeDeclaration? I have tried to be as specific as necessary, but I am happy to give out more information should it be needed. Any and all help is appreciated greatly!
    Last edited by Benjay; July 14th, 2005 at 02:34 PM.

  2. #2
    Join Date
    Sep 2003
    Posts
    21

    Re: Xerces C++ schema parsing

    In case anyone else ever encounters this problem, I'll post the solution.

    I was expecting the XSAttributeDeclaration to be the object I needed to reference to get the information I needed. It is actually the XSAttributeUse object that I had to reference, using the "getConstraintValue()" method.

    The XSAttributeUse object can be obtained from the XSElementDeclaration by first getting the XSComplexTypeDefinition, and from that object getting the XSAttributeUseList.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured