Package org.apache.xerces.framework

Examples of org.apache.xerces.framework.XMLContentSpecNode


        //
        //  Get the content spec node for the element we are working on.
        //  This will tell us what kind of node it is, which tells us what
        //  kind of model we will try to create.
        //
        XMLContentSpecNode specNode = new XMLContentSpecNode();
        int contentSpecIndex = getContentSpecHandle(elementIndex);
        getContentSpecNode(contentSpecIndex, specNode);

        //
        //  Check that the left value is not -1, since any content model
        //  with PCDATA should be MIXED, so we should not have gotten here.
        //
        if (specNode.value == -1)
            throw new CMException(ImplementationMessages.VAL_NPCD);

        if (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
        {
            //
            //  Its a single leaf, so its an 'a' type of content model, i.e.
            //  just one instance of one element. That one is definitely a
            //  simple content model.
            //
            return new SimpleContentModel(specNode.value, -1, specNode.type);
        }
         else if ((specNode.type == XMLContentSpecNode.CONTENTSPECNODE_CHOICE)
              ||  (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_SEQ))
        {
            //
            //  Lets see if both of the children are leafs. If so, then it
            //  it has to be a simple content model
            //
            XMLContentSpecNode specLeft = new XMLContentSpecNode();
            XMLContentSpecNode specRight = new XMLContentSpecNode();
            getContentSpecNode(specNode.value, specLeft);
            getContentSpecNode(specNode.otherValue, specRight);

            if ((specLeft.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
            &&  (specRight.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF))
            {
                //
                //  Its a simple choice or sequence, so we can do a simple
                //  content model for it.
                //
                return new SimpleContentModel
                (
                    specLeft.value
                    , specRight.value
                    , specNode.type
                );
            }
        }
         else if ((specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_ONE)
              ||  (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_MORE)
              ||  (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ONE_OR_MORE))
        {
            //
            //  Its a repetition, so see if its one child is a leaf. If so
            //  its a repetition of a single element, so we can do a simple
            //  content model for that.
            //
            XMLContentSpecNode specLeft = new XMLContentSpecNode();
            getContentSpecNode(specNode.value, specLeft);

            if (specLeft.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
            {
                //
View Full Code Here


        {
            //
            //  Just create a mixel content model object. This type of
            //  content model is optimized for mixed content validation.
            //
            XMLContentSpecNode specNode = new XMLContentSpecNode();
            int contentSpecIndex = getContentSpecHandle(elementIndex);
            makeContentList(contentSpecIndex, specNode);
            cmRet = new MixedContentModel(fCount, fContentList);
        }
         else if (contentSpec == fCHILDRENSymbol)
View Full Code Here

        //
        //  Get the content spec node for the element we are working on.
        //  This will tell us what kind of node it is, which tells us what
        //  kind of model we will try to create.
        //
        XMLContentSpecNode specNode = new XMLContentSpecNode();
        int contentSpecIndex = fElementDeclPool.getContentSpec(elementIndex);
        fElementDeclPool.getContentSpecNode(contentSpecIndex, specNode);

        //
        //  Check that the left value is not -1, since any content model
        //  with PCDATA should be MIXED, so we should not have gotten here.
        //
        if (specNode.value == -1)
            throw new CMException(ImplementationMessages.VAL_NPCD);

        if (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
        {
            //
            //  Its a single leaf, so its an 'a' type of content model, i.e.
            //  just one instance of one element. That one is definitely a
            //  simple content model.
            //
            return new SimpleContentModel(specNode.value, -1, specNode.type);
        }
         else if ((specNode.type == XMLContentSpecNode.CONTENTSPECNODE_CHOICE)
              ||  (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_SEQ))
        {
            //
            //  Lets see if both of the children are leafs. If so, then it
            //  it has to be a simple content model
            //
            XMLContentSpecNode specLeft = new XMLContentSpecNode();
            XMLContentSpecNode specRight = new XMLContentSpecNode();
            fElementDeclPool.getContentSpecNode(specNode.value, specLeft);
            fElementDeclPool.getContentSpecNode(specNode.otherValue, specRight);

            if ((specLeft.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
            &&  (specRight.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF))
            {
                //
                //  Its a simple choice or sequence, so we can do a simple
                //  content model for it.
                //
                return new SimpleContentModel
                (
                    specLeft.value
                    , specRight.value
                    , specNode.type
                );
            }
        }
         else if ((specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_ONE)
              ||  (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_MORE)
              ||  (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ONE_OR_MORE))
        {
            //
            //  Its a repetition, so see if its one child is a leaf. If so
            //  its a repetition of a single element, so we can do a simple
            //  content model for that.
            //
            XMLContentSpecNode specLeft = new XMLContentSpecNode();
            fElementDeclPool.getContentSpecNode(specNode.value, specLeft);

            if (specLeft.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
            {
                //
View Full Code Here

        {
            //
            //  Just create a mixel content model object. This type of
            //  content model is optimized for mixed content validation.
            //
            XMLContentSpecNode specNode = new XMLContentSpecNode();
            int contentSpecIndex = fElementDeclPool.getContentSpec(elementIndex);
            makeContentList(contentSpecIndex, specNode);
            cmRet = new MixedContentModel(fCount, fContentList);
        }
         else if (contentSpec == fStringPool.addSymbol("CHILDREN"))
View Full Code Here

        // build all model
        if (count > 1) {

            // create and initialize singletons
            XMLContentSpecNode choice = new XMLContentSpecNode();

            choice.type = XMLContentSpecNode.CONTENTSPECNODE_CHOICE;
            choice.value = -1;
            choice.otherValue = -1;
View Full Code Here

            }
        }
*/
        try { // REVISIT - integrate w/ error handling
            int contentSpecIndex = fElementDeclPool.getContentSpec(fChild);
            XMLContentSpecNode csn = new XMLContentSpecNode();
            fElementDeclPool.getContentSpecNode(contentSpecIndex, csn);
            String type = fStringPool.toString(csn.value);
            DatatypeValidator v = fDatatypeRegistry.getValidatorFor(type);
            if (v != null)
                v.validate(fStringPool.toString(children[0]));
View Full Code Here

                    int attributeIndex = fDeferredDocumentImpl.createAttribute(fStringPool.addSymbol("content"), fStringPool.addString("elemOnly"), false);
                    fDeferredDocumentImpl.setAttributeNode(archetypeIndex, attributeIndex);
                    attributeIndex = fDeferredDocumentImpl.createAttribute(fStringPool.addSymbol("order"), fStringPool.addString("seq"), false);
                    fDeferredDocumentImpl.setAttributeNode(archetypeIndex, attributeIndex);

                    XMLContentSpecNode node = new XMLContentSpecNode();
                    int contentSpecIndex = contentSpec.getHandle();
                    contentSpec.getNode(contentSpecIndex, node);
                    Element model = createContentModel(contentSpec, node);

                    int modelIndex = createDeferredContentModel(model);
                    int firstChildIndex = getFirstChildElement(archetypeIndex);
                    fDeferredDocumentImpl.insertBefore(archetypeIndex, modelIndex, firstChildIndex);
                }
                else {
                    // REVISIT: Any chance of getting other than MIXED? -Ac
                    int attributeIndex = fDeferredDocumentImpl.createAttribute(fStringPool.addSymbol("content"), fStringPool.addString("mixed"), true);
                    fDeferredDocumentImpl.setAttributeNode(archetypeIndex, attributeIndex);

                    XMLContentSpecNode node = new XMLContentSpecNode();
                    int index = contentSpec.getHandle();
                    contentSpec.getNode(index, node);
                    if (node.type != 0) {

                        // skip '*' node
                        contentSpec.getNode(node.value, node);

                        // add leaves (on descent)
                        do {
                            index = node.value;
                            int handle = fAttrList.startAttrList();
                            contentSpec.getNode(node.otherValue, node);
                            String elementRefName = fStringPool.toString(node.value);
                            fAttrList.addAttr(
                                fStringPool.addSymbol("ref"),
                                fStringPool.addString(elementRefName),
                                fStringPool.addSymbol("NMTOKEN"),
                                true,
                                false); // search
                            fAttrList.endAttrList();
                            int elementRefIndex = fDeferredDocumentImpl.createElement(fStringPool.addSymbol("element"), fAttrList, handle);
                            fDeferredDocumentImpl.insertBefore(archetypeIndex, elementRefIndex, getFirstChildElement(archetypeIndex, "element"));
                            contentSpec.getNode(index, node);
                        } while (node.type != XMLContentSpecNode.CONTENTSPECNODE_LEAF);
                    }
                }

            } // if defer-node-expansion

            else if (fDocumentImpl != null) {

                // get element declaration; create if necessary
                Element schema = XUtil.getFirstChildElement(fDocumentType, "schema");
                String elementName = fStringPool.toString(elementTypeIndex);
                Element element = XUtil.getFirstChildElement(schema, "element", "name", elementName);
                if (element == null) {
                    element = fDocument.createElement("element");
                    element.setAttribute("name", elementName);
                    element.setAttribute("export", "true");
                    ((AttrImpl)element.getAttributeNode("export")).setSpecified(false);
                    schema.appendChild(element);
                }

                // get archetype element; create if necessary
                Element archetype = XUtil.getFirstChildElement(element, "archetype");
                if (archetype == null) {
                    archetype = fDocument.createElement("archetype");
                    // REVISIT: Check for archetype redeclaration? -Ac
                    element.insertBefore(archetype, XUtil.getFirstChildElement(element));
                }

                // build content model
                int contentType = contentSpec.getType();
                String contentTypeName = fStringPool.toString(contentType);
                if (contentTypeName.equals("EMPTY")) {
                    archetype.setAttribute("content", "empty");
                }
                else if (contentTypeName.equals("ANY")) {
                    archetype.setAttribute("content", "any");
                }
                else if (contentTypeName.equals("CHILDREN")) {

                    // build content model
                    archetype.setAttribute("content", "elemOnly");
                    ((AttrImpl)archetype.getAttributeNode("content")).setSpecified(false);
                    archetype.setAttribute("order", "seq");
                    ((AttrImpl)archetype.getAttributeNode("order")).setSpecified(false);
                    XMLContentSpecNode node = new XMLContentSpecNode();
                    int handle = contentSpec.getHandle();
                    contentSpec.getNode(handle, node);

                    Element model = createContentModel(contentSpec, node);
                    Element firstChild = XUtil.getFirstChildElement(archetype);
                    archetype.insertBefore(model, firstChild);
                }
                else {
                    // REVISIT: Any chance of getting other than MIXED? -Ac
                    archetype.setAttribute("content", "mixed");
                    XMLContentSpecNode node = new XMLContentSpecNode();
                    int handle = contentSpec.getHandle();
                    contentSpec.getNode(handle, node);
                    if (node.type != 0) {

                        // skip '*' node
View Full Code Here

                    int attributeIndex = fDeferredDocumentImpl.createAttribute(fStringPool.addSymbol("content"), fStringPool.addString("elemOnly"), false);
                    fDeferredDocumentImpl.setAttributeNode(archetypeIndex, attributeIndex);
                    attributeIndex = fDeferredDocumentImpl.createAttribute(fStringPool.addSymbol("order"), fStringPool.addString("seq"), false);
                    fDeferredDocumentImpl.setAttributeNode(archetypeIndex, attributeIndex);

                    XMLContentSpecNode node = new XMLContentSpecNode();
                    int contentSpecIndex = contentSpec.getHandle();
                    contentSpec.getNode(contentSpecIndex, node);
                    Element model = createContentModel(contentSpec, node);

                    int modelIndex = createDeferredContentModel(model);
                    int firstChildIndex = getFirstChildElement(archetypeIndex);
                    fDeferredDocumentImpl.insertBefore(archetypeIndex, modelIndex, firstChildIndex);
                }
                else {
                    // REVISIT: Any chance of getting other than MIXED? -Ac
                    int attributeIndex = fDeferredDocumentImpl.createAttribute(fStringPool.addSymbol("content"), fStringPool.addString("mixed"), true);
                    fDeferredDocumentImpl.setAttributeNode(archetypeIndex, attributeIndex);

                    XMLContentSpecNode node = new XMLContentSpecNode();
                    int index = contentSpec.getHandle();
                    contentSpec.getNode(index, node);
                    if (node.type != 0) {

                        // skip '*' node
                        contentSpec.getNode(node.value, node);

                        // add leaves (on descent)
                        do {
                            index = node.value;
                            int handle = fAttrList.startAttrList();
                            contentSpec.getNode(node.otherValue, node);
                            String elementRefName = fStringPool.toString(node.value);
                            fAttrList.addAttr(
                                fStringPool.addSymbol("ref"),
                                fStringPool.addString(elementRefName),
                                fStringPool.addSymbol("NMTOKEN"),
                                true,
                                false); // search
                            fAttrList.endAttrList();
                            int elementRefIndex = fDeferredDocumentImpl.createElement(fStringPool.addSymbol("element"), fAttrList, handle);
                            fDeferredDocumentImpl.insertBefore(archetypeIndex, elementRefIndex, getFirstChildElement(archetypeIndex, "element"));
                            contentSpec.getNode(index, node);
                        } while (node.type != XMLContentSpecNode.CONTENTSPECNODE_LEAF);
                    }
                }

            } // if defer-node-expansion

            else if (fDocumentImpl != null) {

                // get element declaration; create if necessary
                Element schema = XUtil.getFirstChildElement(fDocumentType, "schema");
                String elementName = fStringPool.toString(elementTypeIndex);
                Element element = XUtil.getFirstChildElement(schema, "element", "name", elementName);
                if (element == null) {
                    element = fDocument.createElement("element");
                    element.setAttribute("name", elementName);
                    element.setAttribute("export", "true");
                    ((AttrImpl)element.getAttributeNode("export")).setSpecified(false);
                    schema.appendChild(element);
                }

                // get archetype element; create if necessary
                Element archetype = XUtil.getFirstChildElement(element, "archetype");
                if (archetype == null) {
                    archetype = fDocument.createElement("archetype");
                    // REVISIT: Check for archetype redeclaration? -Ac
                    element.insertBefore(archetype, XUtil.getFirstChildElement(element));
                }

                // build content model
                int contentType = contentSpec.getType();
                String contentTypeName = fStringPool.toString(contentType);
                if (contentTypeName.equals("EMPTY")) {
                    archetype.setAttribute("content", "empty");
                }
                else if (contentTypeName.equals("ANY")) {
                    archetype.setAttribute("content", "any");
                }
                else if (contentTypeName.equals("CHILDREN")) {

                    // build content model
                    archetype.setAttribute("content", "elemOnly");
                    ((AttrImpl)archetype.getAttributeNode("content")).setSpecified(false);
                    archetype.setAttribute("order", "seq");
                    ((AttrImpl)archetype.getAttributeNode("order")).setSpecified(false);
                    XMLContentSpecNode node = new XMLContentSpecNode();
                    int handle = contentSpec.getHandle();
                    contentSpec.getNode(handle, node);

                    Element model = createContentModel(contentSpec, node);
                    Element firstChild = XUtil.getFirstChildElement(archetype);
                    archetype.insertBefore(model, firstChild);
                }
                else {
                    // REVISIT: Any chance of getting other than MIXED? -Ac
                    archetype.setAttribute("content", "mixed");
                    XMLContentSpecNode node = new XMLContentSpecNode();
                    int handle = contentSpec.getHandle();
                    contentSpec.getNode(handle, node);
                    if (node.type != 0) {

                        // skip '*' node
View Full Code Here

        //
        //  Get the content spec node for the element we are working on.
        //  This will tell us what kind of node it is, which tells us what
        //  kind of model we will try to create.
        //
        XMLContentSpecNode specNode = new XMLContentSpecNode();
        int contentSpecIndex = fElementDeclPool.getContentSpec(elementIndex);
        fElementDeclPool.getContentSpecNode(contentSpecIndex, specNode);

        //
        //  Check that the left value is not -1, since any content model
        //  with PCDATA should be MIXED, so we should not have gotten here.
        //
        if (specNode.value == -1)
            throw new CMException(ImplementationMessages.VAL_NPCD);

        if (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
        {
            //
            //  Its a single leaf, so its an 'a' type of content model, i.e.
            //  just one instance of one element. That one is definitely a
            //  simple content model.
            //
            return new SimpleContentModel(specNode.value, -1, specNode.type);
        }
         else if ((specNode.type == XMLContentSpecNode.CONTENTSPECNODE_CHOICE)
              ||  (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_SEQ))
        {
            //
            //  Lets see if both of the children are leafs. If so, then it
            //  it has to be a simple content model
            //
            XMLContentSpecNode specLeft = new XMLContentSpecNode();
            XMLContentSpecNode specRight = new XMLContentSpecNode();
            fElementDeclPool.getContentSpecNode(specNode.value, specLeft);
            fElementDeclPool.getContentSpecNode(specNode.otherValue, specRight);

            if ((specLeft.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
            &&  (specRight.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF))
            {
                //
                //  Its a simple choice or sequence, so we can do a simple
                //  content model for it.
                //
                return new SimpleContentModel
                (
                    specLeft.value
                    , specRight.value
                    , specNode.type
                );
            }
        }
         else if ((specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_ONE)
              ||  (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_MORE)
              ||  (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ONE_OR_MORE))
        {
            //
            //  Its a repetition, so see if its one child is a leaf. If so
            //  its a repetition of a single element, so we can do a simple
            //  content model for that.
            //
            XMLContentSpecNode specLeft = new XMLContentSpecNode();
            fElementDeclPool.getContentSpecNode(specNode.value, specLeft);

            if (specLeft.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
            {
                //
View Full Code Here

        {
            //
            //  Just create a mixel content model object. This type of
            //  content model is optimized for mixed content validation.
            //
            XMLContentSpecNode specNode = new XMLContentSpecNode();
            int contentSpecIndex = fElementDeclPool.getContentSpec(elementIndex);
            makeContentList(contentSpecIndex, specNode);
            cmRet = new MixedContentModel(fCount, fContentList);
        }
         else if (contentSpec == fStringPool.addSymbol("CHILDREN"))
View Full Code Here

TOP

Related Classes of org.apache.xerces.framework.XMLContentSpecNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.