< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java

Print this page


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Nov 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xerces.internal.impl.xs.traversers;
  23 
  24 import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
  25 import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
  26 import com.sun.org.apache.xerces.internal.impl.xs.XSElementDecl;
  27 import com.sun.org.apache.xerces.internal.impl.xs.identity.IdentityConstraint;
  28 import com.sun.org.apache.xerces.internal.impl.xs.identity.UniqueOrKey;
  29 import com.sun.org.apache.xerces.internal.util.DOMUtil;
  30 import org.w3c.dom.Element;
  31 
  32 /**
  33  * This class contains code that is used to traverse both <key>s and
  34  * <unique>s.
  35  *
  36  * @xerces.internal
  37  *
  38  * @author Neil Graham, IBM

  39  */
  40 class XSDUniqueOrKeyTraverser extends XSDAbstractIDConstraintTraverser {
  41 
  42     public XSDUniqueOrKeyTraverser (XSDHandler handler,
  43                                   XSAttributeChecker gAttrCheck) {
  44         super(handler, gAttrCheck);
  45     }
  46 
  47 
  48     void traverse(Element uElem, XSElementDecl element,
  49             XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
  50 
  51         // General Attribute Checking
  52         Object[] attrValues = fAttrChecker.checkAttributes(uElem, false, schemaDoc);
  53 
  54         // create identity constraint
  55         String uName = (String)attrValues[XSAttributeChecker.ATTIDX_NAME];
  56 
  57         if(uName == null){
  58             reportSchemaError("s4s-att-must-appear", new Object [] {DOMUtil.getLocalName(uElem) , SchemaSymbols.ATT_NAME }, uElem);


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.

   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.impl.xs.traversers;
  22 
  23 import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
  24 import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols;
  25 import com.sun.org.apache.xerces.internal.impl.xs.XSElementDecl;
  26 import com.sun.org.apache.xerces.internal.impl.xs.identity.IdentityConstraint;
  27 import com.sun.org.apache.xerces.internal.impl.xs.identity.UniqueOrKey;
  28 import com.sun.org.apache.xerces.internal.util.DOMUtil;
  29 import org.w3c.dom.Element;
  30 
  31 /**
  32  * This class contains code that is used to traverse both <key>s and
  33  * <unique>s.
  34  *
  35  * @xerces.internal
  36  *
  37  * @author Neil Graham, IBM
  38  * @LastModified: Nov 2017
  39  */
  40 class XSDUniqueOrKeyTraverser extends XSDAbstractIDConstraintTraverser {
  41 
  42     public XSDUniqueOrKeyTraverser (XSDHandler handler,
  43                                   XSAttributeChecker gAttrCheck) {
  44         super(handler, gAttrCheck);
  45     }
  46 
  47 
  48     void traverse(Element uElem, XSElementDecl element,
  49             XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
  50 
  51         // General Attribute Checking
  52         Object[] attrValues = fAttrChecker.checkAttributes(uElem, false, schemaDoc);
  53 
  54         // create identity constraint
  55         String uName = (String)attrValues[XSAttributeChecker.ATTIDX_NAME];
  56 
  57         if(uName == null){
  58             reportSchemaError("s4s-att-must-appear", new Object [] {DOMUtil.getLocalName(uElem) , SchemaSymbols.ATT_NAME }, uElem);


< prev index next >