Package org.apache.xerces.utils

Examples of org.apache.xerces.utils.QName


        // elements or elements that aren't permitted.
        boolean elementSeen[] = new boolean[numElements];
        int numRequiredSeen = 0;

        childLoop: for (int childIndex = 0; childIndex < length; childIndex++) {
            QName currChild = children[offset + childIndex];

            // Skip text node if in mixed mode.
            if (fIsMixed && currChild.localpart == -1)
                continue;
View Full Code Here


        // elements that aren't permitted, up to insertion point.
        boolean elementSeen[] = new boolean[numElements];

        final int numChildren = info.curChildren.length;
        final int insertAt = info.insertAt;
        final QName curChildren[] = info.curChildren;

        for (int childIndex = 0; childIndex < insertAt; childIndex++) {
            QName currChild = curChildren[childIndex];

            Integer foundIdx = (Integer)fElementsHash.get(currChild);

            // If this element was not found in the Hashtable of permitted
            // elements or was seen already, indicate an error was found
            // at the current index.
            if (foundIdx == null)
                return childIndex;

            int foundIdxVal = foundIdx.intValue();

            if (elementSeen[foundIdxVal])
                return childIndex;

            elementSeen[foundIdxVal] = true;
        }

        info.canHoldPCData = fIsMixed;

        final int resultsCount = numElements - insertAt;
        info.resultsCount = resultsCount;

        //
        //  If the outgoing arrays are too small or null, create new ones. These
        //  have to be at least the size of the results count.
        //
        if ((info.results == null) || (info.results.length < resultsCount))
            info.results = new boolean[resultsCount];

        if ((info.possibleChildren == null)
        ||  (info.possibleChildren.length < resultsCount))
        {
            info.possibleChildren = new QName[resultsCount];

            QName possibleChildren[] = info.possibleChildren;
            final int possibleChildrenLen = info.possibleChildren.length;

            for (int i = 0; i < possibleChildrenLen; i++) {
                possibleChildren[i] = new QName();
            }
        }

        int possibleChildIdx = 0;
View Full Code Here

      entityHandler.setEventHandler(this);
      entityHandler.setCharDataHandler(this);
      fDocumentScanner.setEventHandler(this);

      for (int i = 0; i < sizeQNameParts; i++) {
         fElementQNamePartsStack[i] = new QName();
      }
      init();

   } // <init>(StringPool,XMLErrorReporter,DefaultEntityHandler,XMLDocumentScanner)
View Full Code Here

         if (fElementChildren.length <= fElementChildrenLength) {
            QName[] newarray = new QName[fElementChildrenLength * 2];
            System.arraycopy(fElementChildren, 0, newarray, 0, fElementChildren.length);
            fElementChildren = newarray;
         }
         QName qname = fElementChildren[fElementChildrenLength];
         if (qname == null) {
            for (int i = fElementChildrenLength; i < fElementChildren.length; i++) {
               fElementChildren[i] = new QName();
            }
            qname = fElementChildren[fElementChildrenLength];
         }
         qname.setValues(element);
         fElementChildrenLength++;

         if (DEBUG_ELEMENT_CHILDREN) {
            printChildren();
            printStack();
View Full Code Here

         QName[] newStackOfQueue = new QName[newElementDepth * 2];
         System.arraycopy(this.fElementQNamePartsStack, 0, newStackOfQueue, 0, newElementDepth );
         fElementQNamePartsStack      = newStackOfQueue;

         QName qname = fElementQNamePartsStack[newElementDepth];
         if (qname == null) {
            for (int i = newElementDepth; i < fElementQNamePartsStack.length; i++) {
               fElementQNamePartsStack[i] = new QName();
            }
         }

         newStack = new int[newElementDepth * 2];
         System.arraycopy(fElementEntityStack, 0, newStack, 0, newElementDepth);
View Full Code Here

      fElementDepth--;
      if (fValidating) {
         int elementIndex = fCurrentElementIndex;
         if (elementIndex != -1 && fCurrentContentSpecType != -1) {
            QName children[] = fElementChildren;
            int childrenOffset = fElementChildrenOffsetStack[fElementDepth + 1] + 1;
            int childrenLength = fElementChildrenLength - childrenOffset;
            if (DEBUG_ELEMENT_CHILDREN) {
               System.out.println("endElement("+fStringPool.toString(fCurrentElement.rawname)+')');
               System.out.println("fCurrentContentSpecType : " + fCurrentContentSpecType );
View Full Code Here

      if (fElementChildren.length <= fElementChildrenLength) {
         QName[] newarray = new QName[fElementChildren.length * 2];
         System.arraycopy(fElementChildren, 0, newarray, 0, fElementChildren.length);
         fElementChildren = newarray;
      }
      QName qname = fElementChildren[fElementChildrenLength];
      if (qname == null) {
         for (int i = fElementChildrenLength; i < fElementChildren.length; i++) {
            fElementChildren[i] = new QName();
         }
         qname = fElementChildren[fElementChildrenLength];
      }
      qname.clear();
      fElementChildrenLength++;

   } // charDataInCount()
View Full Code Here

   private void printChildren() {
      if (DEBUG_ELEMENT_CHILDREN) {
         System.out.print('[');
         for (int i = 0; i < fElementChildrenLength; i++) {
            System.out.print(' ');
            QName qname = fElementChildren[i];
            if (qname != null) {
               System.out.print(fStringPool.toString(qname.rawname));
            } else {
               System.out.print("null");
            }
View Full Code Here

                if (childName.equals(SchemaSymbols.ELT_ELEMENT)) {
                    if (mixedContent || elementContent) {
                        if ( DEBUGGING )
                            System.out.println(" child element name " + child.getAttribute(SchemaSymbols.ATT_NAME));

                        QName eltQName = traverseElementDecl(child);
                        index = fSchemaGrammar.addContentSpecNode( XMLContentSpec.CONTENTSPECNODE_LEAF,
                                                                   eltQName.localpart,
                                                                   eltQName.uri,
                                                                   false);
                        seeParticle = true;
                        seeOtherParticle = true;

                    }
                    else {
                        reportSchemaError(SchemaMessageProvider.EltRefOnlyInMixedElemOnly, null);
                    }

                }
                else if (childName.equals(SchemaSymbols.ELT_GROUP)) {
                    index = traverseGroupDecl(child);
                    if (index == -1)
                        continue;
                    seeParticle = true;
                    seeOtherParticle = true;
                }
                else if (childName.equals(SchemaSymbols.ELT_ALL)) {
                    index = traverseAll(child);
                    seeParticle = true;
                    seeAll = true;
                 
                }
                else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
                    index = traverseChoice(child);
                    seeParticle = true;
                    seeOtherParticle = true;                 
                }
                else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
                    index = traverseSequence(child);
                    seeParticle = true;
                    seeOtherParticle = true;                 
                }
                else if (childName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
                           childName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
                    break; // attr processing is done later on in this method
                }
                else if (childName.equals(SchemaSymbols.ELT_ANY)) {

                    index = traverseAny(child);
                    seeParticle = true;
                    seeOtherParticle = true;
                }
                else if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
                    //REVISIT, do nothing for annotation for now.
                }
                else if (childName.equals(SchemaSymbols.ELT_ANYATTRIBUTE)) {
                    break;
                    //REVISIT, do nothing for attribute wildcard for now.
                }
                else { // datatype qual
                    if (!baseIsComplexSimple )
                    if (base.equals(""))
                        reportSchemaError(SchemaMessageProvider.GenericError,
                                          new Object [] { "unrecognized child '"+childName+"' in complex type "+typeName });
                    else
                        reportSchemaError(SchemaMessageProvider.GenericError,
                                          new Object [] { "unrecognized child '"+childName+"' in complex type '"+typeName+"' with base "+base  });
                }

                // if base is complextype with simpleType content, can't have any particle children at all.
                if (baseIsComplexSimple && seeParticle) {
                    // REVISIT: Localize
                    reportGenericSchemaError("In complexType "+typeName+", base type is complexType with simpleType content, can't have any particle children at all");
                    hadContent = false;
                    left = index = -2;
                    contentSpecType = XMLElementDecl.TYPE_SIMPLE;
                    break;
                }


                if (seeAll && seeOtherParticle) {
                    // REVISIT: Localize
                    reportGenericSchemaError ( " 'All' group needs to be the only child in Complextype : " + typeName);
                }

                if (seeAll) {
                    //TO DO: REVISIT
                    //check the minOccurs = 1 and maxOccurs = 1 
                }

                // check the minOccurs and maxOccurs of the particle, and fix the 
                // contentspec accordingly
                if (seeParticle) {
                    index = expandContentModel(index, child);
                    if (index == -2 ) {
                        continue;
                    }
                } //end of if (seeParticle)

                if (left == -2) {
                    left = index;
                } else if (right == -2) {
                    right = index;
                } else {
                    left = fSchemaGrammar.addContentSpecNode(csnType, left, right, false);
                    right = index;
                }
            } //end looping through the children

            if ( ! ( seeOtherParticle || seeAll ) && (elementContent || mixedContent)
                 &&  (base.length() == 0 || ( base.length() > 0 && derivedByRestriction && !baseIsComplexSimple))  ) {
                contentSpecType = XMLElementDecl.TYPE_SIMPLE;
                simpleTypeValidator = getDatatypeValidator("", SchemaSymbols.ATTVAL_STRING);
                // REVISIT: Localize
                reportGenericSchemaError ( " complexType '"+typeName+"' with a elementOnly or mixed content "
                                           +"need to have at least one particle child");
            }

            if (hadContent && right != -2)
                left = fSchemaGrammar.addContentSpecNode(csnType, left, right, false);

            if (mixedContent && hadContent) {
                // set occurrence count
                left = fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE,
                                                     left, -1, false);
            }
        }

        // if derived by extension and base complextype has a content model,
        // compose the final content model by concatenating the base and the
        // current in sequence.
        if (!derivedByRestriction && baseContentSpecHandle > -1 ) {
            if (baseFromAnotherSchema ) {
                SchemaGrammar aGrammar = (SchemaGrammar) fGrammarResolver.getGrammar(baseTypeSchemaURI);
                baseContentSpecHandle = importContentSpec(aGrammar, baseContentSpecHandle);
            }
           
            if (left == -2) {
                left = baseContentSpecHandle;
            }
            else
                left = fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_SEQ,
                                                         baseContentSpecHandle,
                                                         left,
                                                         false);
        }

        // REVISIT: this is when sees a topelevel <complexType name="abc">attrs*</complexType>
        if (content.length() == 0 && base.length() == 0 && left == -2) {
            contentSpecType = XMLElementDecl.TYPE_ANY;
        }

        if (content.length() == 0 && simpleTypeValidator == null && left == -2 ) {
            if (base.length() > 0 && baseTypeInfo != null
                && baseTypeInfo.contentType == XMLElementDecl.TYPE_EMPTY) {
                contentSpecType = XMLElementDecl.TYPE_EMPTY;
            }
        }

        if ( DEBUGGING )
            System.out.println("!!!!!>>>>>" + typeName+", "+ baseTypeInfo + ", "
                               + baseContentSpecHandle +", " + left +", "+scopeDefined);

        ComplexTypeInfo typeInfo = new ComplexTypeInfo();
        typeInfo.baseComplexTypeInfo = baseTypeInfo;
        typeInfo.baseDataTypeValidator = baseTypeValidator;
        int derivedByInt = -1;
        if (derivedBy.length() > 0) {
            derivedByInt = parseComplexDerivedBy(derivedBy);
        }
        typeInfo.derivedBy = derivedByInt;
        typeInfo.scopeDefined = scopeDefined;
        typeInfo.contentSpecHandle = left;
        typeInfo.contentType = contentSpecType;
        typeInfo.datatypeValidator = simpleTypeValidator;
        typeInfo.blockSet = parseBlockSet(complexTypeDecl.getAttribute(SchemaSymbols.ATT_BLOCK));
        typeInfo.finalSet = parseFinalSet(complexTypeDecl.getAttribute(SchemaSymbols.ATT_FINAL));
        typeInfo.isAbstract = isAbstract.equals(SchemaSymbols.ATTVAL_TRUE) ? true:false ;

        //add a template element to the grammar element decl pool.
        int typeNameIndex = fStringPool.addSymbol(typeName);
        int templateElementNameIndex = fStringPool.addSymbol("$"+typeName);

        typeInfo.templateElementIndex =
            fSchemaGrammar.addElementDecl(new QName(-1, templateElementNameIndex,typeNameIndex,fTargetNSURI),
                                          (fTargetNSURI==-1) ? -1 : fCurrentScope, scopeDefined,
                                            contentSpecType, left,
                                          -1, simpleTypeValidator);
        typeInfo.attlistHead = fSchemaGrammar.getFirstAttributeDeclIndex(typeInfo.templateElementIndex);

View Full Code Here

    private void checkRecursingComplexType() throws Exception {
        if ( fCurrentTypeNameStack.empty() ) {
            if (! fElementRecurseComplex.isEmpty() ) {
                Enumeration e = fElementRecurseComplex.keys();
                while( e.hasMoreElements() ) {
                    QName nameThenScope = (QName) e.nextElement();
                    String typeName = (String) fElementRecurseComplex.get(nameThenScope);

                    int eltUriIndex = nameThenScope.uri;
                    int eltNameIndex = nameThenScope.localpart;
                    int enclosingScope = nameThenScope.prefix;
                    ComplexTypeInfo typeInfo =
                        (ComplexTypeInfo) fComplexTypeRegistry.get(fTargetNSURIString+","+typeName);
                    if (typeInfo==null) {
                        throw new Exception ( "Internal Error in void checkRecursingComplexType(). " );
                    }
                    else {
                        int elementIndex = fSchemaGrammar.addElementDecl(new QName(-1, eltNameIndex, eltNameIndex, eltUriIndex),
                                                                         enclosingScope, typeInfo.scopeDefined,
                                                                         typeInfo.contentType,
                                                                         typeInfo.contentSpecHandle,
                                                                         typeInfo.attlistHead,
                                                                         typeInfo.datatypeValidator);
View Full Code Here

TOP

Related Classes of org.apache.xerces.utils.QName

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.