Package org.apache.ws.jaxme.xs.xml

Examples of org.apache.ws.jaxme.xs.xml.XsQName


    // Build the Map of substitution groups.
    Map substitutionGroups = new HashMap();
    for (int i = 0;  i < myChilds.length;  i++) {
      if (myChilds[i] instanceof XSElement) {
        XSElement element = (XSElement) myChilds[i];
        XsQName qName = element.getSubstitutionGroupName();
        if (qName != null) {
          SubstitutionGroup group = (SubstitutionGroup) substitutionGroups.get(qName);
          if (group == null) {
            XSElement head = pSchema.getElement(qName);
            if (head == null) {
              throw new LocSAXException("The substituted element " + qName + " is missing in the schema.",
                  element.getLocator());
            }
            if (head.isBlockedForSubstitution()) {
              throw new LocSAXException("The substituted element " + qName + " is blocked for substitution.",
                  element.getLocator());
            }
            group = new SubstitutionGroup(head);
            if (!head.isAbstract()) {
              group.addMember(head);
            }
            substitutionGroups.put(qName, group);
          }
          group.addMember(element);
        }
      }
    }
   
    // For any substitution group: Build an implicit choice group, which
    // may be used to replace the substitution groups head, if required.
    for (Iterator iter = substitutionGroups.values().iterator();  iter.hasNext()) {
      SubstitutionGroup group = (SubstitutionGroup) iter.next();
      XSElementImpl head = (XSElementImpl) group.getHead();
      XsObject object = head.getXsObject();
      XsESchema syntaxSchema = object.getXsESchema();
     
      // Find a name for the group
      String namespace = syntaxSchema.getTargetNamespace().toString();
      String localName = head.getName().getLocalName() + "Group";
      XsQName suggestion = new XsQName(namespace, localName);
      if (pSchema.getGroup(suggestion) != null) {
        for (int i = 0;  ;  i++) {
          suggestion = new XsQName(namespace, localName + i);
          if (pSchema.getGroup(suggestion) == null) {
            break;
          }
        }
      }
     
      XsTNamedGroup namedGroup = object.getObjectFactory().newXsTNamedGroup(syntaxSchema);
      namedGroup.setName(new XsNCName(suggestion.getLocalName()));
      XsTSimpleExplicitGroup choice = namedGroup.createChoice();
      XSElement[] members = group.getMembers();
      for (int j = 0;  j < members.length;  j++) {
        XSElement member = members[j];
        XsTLocalElement memberElement = choice.createElement();
View Full Code Here


                  throw new SAXParseException("Element " + pElement.getName()
                                                + " references an undeclared element " + name,
                                                pLocator);
                }
                XsTLocalElement e = pGroup.createElement();
                e.setRef(new XsQName(getTargetNamespace(), getLocalPart(name)));
                setMultiplicity(e, multiplicity);
            } else if (o instanceof ChildToken) {
                ChildToken ct = (ChildToken) o;
                XsTExplicitGroup group;
                if (ct.type == ChildToken.SEQUENCE) {
View Full Code Here

            throw new SAXParseException("Mixed content model must end with ')' or ')*'",
                                    pLocator);
        }
        pModel = pModel.substring(0, pModel.length()-1);
        if ("".equals(pModel)) {
            XsQName qName = XSString.getInstance().getName();
            qName = new XsQName(qName.getNamespaceURI(), qName.getLocalName(), "xs");
            if (pHasAttributes) {
                XsTLocalComplexType complexType = pElement.createComplexType();
                XsESimpleContent simpleContent = complexType.createSimpleContent();
                XsTSimpleExtensionType ext = simpleContent.createExtension();
                ext.setBase(qName);
                return ext;
            } else {
              pElement.setType(qName);
                return null;
            }
        } else if (!unbounded) {
          throw new SAXParseException("Mixed content must be either #PCDATA or have multiplicity '*'",
                                        pLocator);
        } else {
          XsTLocalComplexType complexType = pElement.createComplexType();
            complexType.setMixed(true);
            XsEChoice choice = complexType.createChoice();
            choice.setMinOccurs(0);
            choice.setMaxOccurs("unbounded");
            while (!"".equals(pModel)) {
              if (pModel.startsWith("|")) {
                pModel = pModel.substring(1).trim();
                } else {
                  throw new SAXParseException("Expected '|' while parsing mixed content", pLocator);
                }
                int offset = pModel.indexOf('|');
                String name;
                if (offset == -1) {
                    name = pModel.trim();
                    pModel = "";
                } else {
                  name = pModel.substring(0, offset).trim();
                    pModel = pModel.substring(offset);
                }
                if (elements.containsKey(name)) {
                  XsTLocalElement e = choice.createElement();
                    e.setRef(new XsQName(getTargetNamespace(), getLocalPart(name)));
                } else {
                  throw new SAXParseException("Element " + pElement.getName()
                                                + " references element " + name
                                                + ", which is not declared",
                                                pLocator);
View Full Code Here

    protected void createAttribute(XsGAttrDecls pAttrDecls, DTDAttribute pAttribute)
            throws SAXException {
        XsTAttribute attr = pAttrDecls.createAttribute();
        attr.setName(new XsNCName(getLocalPart(pAttribute.getName())));
        String type = pAttribute.getType();
        XsQName qName;
        if ("CDATA".equals(type)) {
          qName = XSString.getInstance().getName();
        } else if ("ID".equals(type)) {
          qName = XSID.getInstance().getName();
        } else if ("IDREF".equals(type)) {
            qName = XSIDREF.getInstance().getName();
        } else if ("IDREFS".equals(type)) {
            qName = XSIDREFs.getInstance().getName();
        } else if ("ENTITY".equals(type)) {
            qName = XSEntity.getInstance().getName();
        } else if ("ENTITIES".equals(type)) {
            qName = XSEntities.getInstance().getName();
        } else if ("NMTOKEN".equals(type)) {
            qName = XSNMToken.getInstance().getName();
        } else if ("NMTOKENS".equals(type)) {
            qName = XSNMTokens.getInstance().getName();
        } else {
            if (type.startsWith("NOTATION"&&
                Character.isWhitespace(type.charAt("NOTATION".length()))) {
              qName = XSNotation.getInstance().getName();
            } else {
              qName = XSNMToken.getInstance().getName();
            }
            XsTLocalSimpleType simpleType = attr.createSimpleType();
            XsERestriction restriction = simpleType.createRestriction();
            restriction.setBase(new XsQName(qName.getNamespaceURI(), qName.getLocalName(), "xs"));
            if (type.startsWith("(")) {
              type = type.substring(1).trim();
            } else {
              throw new SAXParseException("The enumeration in the type of attribute "
                                            + pAttribute.getName()
                                            + " must begin with an '('.",
                                            pAttribute.getLocator());
            }
            if (type.endsWith(")")) {
                type = type.substring(0, type.length()-1).trim();
            } else {
                throw new SAXParseException("The enumeration in the type of attribute "
                                            + pAttribute.getName()
                                            + " must begin with an '('.",
                                            pAttribute.getLocator());
            }
            StringTokenizer st = new StringTokenizer(type, "|");
            if (!st.hasMoreTokens()) {
              throw new SAXParseException("The enumeration in the type of attribute "
                                            + pAttribute.getName()
                                            + " contains no tokens.",
                                            pAttribute.getLocator());
            }
            while (st.hasMoreTokens()) {
                String token = st.nextToken().trim();
                if ("".equals(token)) {
                  throw new SAXParseException("The enumeration in the type of attribute "
                                                + pAttribute.getName()
                                                + " contains an empty token.",
                                                pAttribute.getLocator());
                }
                XsEEnumeration enumeration = restriction.createEnumeration();
                enumeration.setValue(token);
            }
            qName = null;
        }
        if (qName != null) {
            attr.setType(new XsQName(qName.getNamespaceURI(), qName.getLocalName(), "xs"));
        }
    }
View Full Code Here

        result.setName(new XsNCName(getLocalPart(pName)));
        XsGAttrDecls attrDecls;
        if ("EMPTY".equals(pModel)) {
          attrDecls = result.createComplexType();
        } else if ("ANY".equals(pModel)) {
            XsQName qName = XSAnyType.getInstance().getName();
            qName = new XsQName(qName.getNamespaceURI(), qName.getLocalName(), "xs");
          if (pAttributes.length == 0) {
                result.setType(qName);
                attrDecls = null;
            } else {
                XsTComplexType complexType = result.createComplexType();
View Full Code Here

          throw new IllegalStateException("Unknown column type: " + myType);
        }
      }

      XSAttribute attr = new JdbcAttribute(pType, pType.getLocator(),
                                           new XsQName((String) null, pColumn.getName().getName()), xsType,
                                           pColumn.isNullable());
      AttributeSGChain chain = (AttributeSGChain) pTypeSG.newAttributeSG(attr);
      AttributeSG attributeSG = new AttributeSGImpl(chain);
      pTypeSG.addAttributeSG(attributeSG);
      theChild = attributeSG;
View Full Code Here

  public void add(XSAnnotation pAnnotation) {
    addChild(pAnnotation);
  }

  public void add(XSType pType) throws SAXException {
    XsQName name = pType.getName();
    if (name == null) {
      throw new LocSAXException("A global type must have a 'name' attribute.", pType.getLocator());
    }
    if (types.containsKey(name)) {
      throw new LocSAXException("A global type " + name + " is already defined.", pType.getLocator());
View Full Code Here

    pType.setGlobal(true);
    addChild(pType);
  }

  public void redefine(XSType pType) throws SAXException {
    XsQName name = pType.getName();
    if (name == null) {
      throw new LocSAXException("A global type must have a 'name' attribute.", pType.getLocator());
    }
    Object oldType = types.get(name);
    if (oldType == null) {
View Full Code Here

    pType.setGlobal(true);
    replace(oldType, pType);
  }

  public void add(XSGroup pGroup) throws SAXException {
    XsQName name = pGroup.getName();
    if (name == null) {
      throw new LocSAXException("A global group must have a 'name' attribute.", pGroup.getLocator());
    }
    if (groups.containsKey(name)) {
      throw new LocSAXException("A global group " + name + " is already defined.", pGroup.getLocator());
View Full Code Here

    addChild(pGroup);
    pGroup.setGlobal(true);
  }

  public void redefine(XSGroup pGroup) throws SAXException {
    XsQName name = pGroup.getName();
    if (name == null) {
      throw new LocSAXException("A global group must have a 'name' attribute.", pGroup.getLocator());
    }
    Object oldGroup = groups.get(name);
    if (oldGroup == null) {
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.xs.xml.XsQName

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.