You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Peter A. Volchek" <Pe...@ti.com.od.ua> on 2001/07/05 19:06:18 UTC

How to get the repetition property ?

Line from *.xsd
<xsd:element name="A" type="TypeA" minOccurs="1" maxOccurs="unbounded"
nillable="true"/>

How could I get the information about minOccurs="1" maxOccurs="unbounded"
properties ?
I expected that following code will return mw what I want

    SchemaGrammar* grammar = (SchemaGrammar*)
parser.getValidator().getGrammar();
    RefHash3KeysIdPoolEnumerator<SchemaElementDecl> elemEnum =
grammar->getElemEnumerator();
    if (elemEnum.hasMoreElements())
    {
        while(elemEnum.hasMoreElements())
        {
            // Element's properties
            const SchemaElementDecl& curElem = elemEnum.nextElement();
            ContentSpecNode* cSpecNode = curElem.getContentSpec();

            if( !cSpecNode) {

    switch( cSpecNode->getType() )
    {
        case ContentSpecNode::Leaf:             cout << "Leaf"; break;
        case ContentSpecNode::ZeroOrOne:        cout << "ZeroOrOne"; break;
        case ContentSpecNode::ZeroOrMore:       cout << "ZeroOrMore"; break;
// That is what I need
    ...
    }


But this does not work
Could you suggest smth ?


Peter A. Volchek
Software Engineer
Metis International, Inc.
PeterV@ti.com.od.ua



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


Re: How to get the repetition property ?

Posted by Khaled Noaman <kn...@ca.ibm.com>.
Hi Peter,

The repetition information is saved in the content spec node
information of a SchemaElementDecl. So, you are right about checking the content
spec node of elements. An element can have a sequence as it content spec node
(e.g. min=2 max=unbounded), in case you want to check for that.
So, your code should work.
I noticed the following in your code snippet:
    >> if (!cSpecNode)
You need to remove the negation from the condition.

Regards,
Khaled

"Peter A. Volchek" wrote:

> Line from *.xsd
> <xsd:element name="A" type="TypeA" minOccurs="1" maxOccurs="unbounded"
> nillable="true"/>
>
> How could I get the information about minOccurs="1" maxOccurs="unbounded"
> properties ?
> I expected that following code will return mw what I want
>
>     SchemaGrammar* grammar = (SchemaGrammar*)
> parser.getValidator().getGrammar();
>     RefHash3KeysIdPoolEnumerator<SchemaElementDecl> elemEnum =
> grammar->getElemEnumerator();
>     if (elemEnum.hasMoreElements())
>     {
>         while(elemEnum.hasMoreElements())
>         {
>             // Element's properties
>             const SchemaElementDecl& curElem = elemEnum.nextElement();
>             ContentSpecNode* cSpecNode = curElem.getContentSpec();
>
>             if( !cSpecNode) {
>
>     switch( cSpecNode->getType() )
>     {
>         case ContentSpecNode::Leaf:             cout << "Leaf"; break;
>         case ContentSpecNode::ZeroOrOne:        cout << "ZeroOrOne"; break;
>         case ContentSpecNode::ZeroOrMore:       cout << "ZeroOrMore"; break;
> // That is what I need
>     ...
>     }
>
> But this does not work
> Could you suggest smth ?
>
> Peter A. Volchek
> Software Engineer
> Metis International, Inc.
> PeterV@ti.com.od.ua
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org