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 Mark Gollop <mj...@ferax.co.uk> on 2002/07/16 12:38:01 UTC

ContentSpecNode formatNode string

If a DTD containd the following element:

    <!ELEMENT suppobj        (descrip?)>

The getFormattedContentModel method will return

    <!ELEMENT suppobj        (descrip)?>

Which is not be parsed correctly by xerces if it were in a dtd.

Either the parser is wrong or formatNode needs to be changed.

The following changes seem to do the trick:
        case ContentSpecNode::ZeroOrOne :
            if (doRepParens)
                bufToFill.append(chOpenParen);
            formatNode(first, curType, bufToFill);
            if (doRepParens && firstType != ContentSpecNode::Leaf)
                bufToFill.append(chCloseParen);
            bufToFill.append(chQuestion);
            if (doRepParens && firstType == ContentSpecNode::Leaf)
                bufToFill.append(chCloseParen);
            break;

        case ContentSpecNode::ZeroOrMore :
            if (doRepParens)
                bufToFill.append(chOpenParen);
            formatNode(first, curType, bufToFill);
            if (doRepParens && firstType != ContentSpecNode::Leaf)
                bufToFill.append(chCloseParen);
            bufToFill.append(chAsterisk);
            if (doRepParens && firstType == ContentSpecNode::Leaf)
                bufToFill.append(chCloseParen);
            break;

        case ContentSpecNode::OneOrMore :
            if (doRepParens)
                bufToFill.append(chOpenParen);
            formatNode(first, curType, bufToFill);
            if (doRepParens && firstType != ContentSpecNode::Leaf)
                bufToFill.append(chCloseParen);
            bufToFill.append(chPlus);
            if (doRepParens && firstType == ContentSpecNode::Leaf)
                bufToFill.append(chCloseParen);
            break;

Regards

Mark
-- 
Mark Gollop
Ferax Software Engineering Limited