1 /*
2 * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Oct 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;
23
555
556 // handlers
557
558 /** Document handler. */
559 protected XMLDocumentHandler fDocumentHandler;
560
561 protected XMLDocumentSource fDocumentSource;
562
563 boolean reportWhitespace = false;
564
565 //
566 // XMLComponent methods
567 //
568
569 /**
570 * Returns a list of feature identifiers that are recognized by
571 * this component. This method may return null if no features
572 * are recognized by this component.
573 */
574 public String[] getRecognizedFeatures() {
575 return (String[]) (RECOGNIZED_FEATURES.clone());
576 } // getRecognizedFeatures():String[]
577
578 /**
579 * Sets the state of a feature. This method is called by the component
580 * manager any time after reset when a feature changes state.
581 * <p>
582 * <strong>Note:</strong> Components should silently ignore features
583 * that do not affect the operation of the component.
584 *
585 * @param featureId The feature identifier.
586 * @param state The state of the feature.
587 *
588 * @throws SAXNotRecognizedException The component should not throw
589 * this exception.
590 * @throws SAXNotSupportedException The component should not throw
591 * this exception.
592 */
593 public void setFeature(String featureId, boolean state) throws XMLConfigurationException {
594 } // setFeature(String,boolean)
595
596 /**
597 * Returns a list of property identifiers that are recognized by
598 * this component. This method may return null if no properties
599 * are recognized by this component.
600 */
601 public String[] getRecognizedProperties() {
602 return (String[]) (RECOGNIZED_PROPERTIES.clone());
603 } // getRecognizedProperties():String[]
604
605 /**
606 * Sets the value of a property. This method is called by the component
607 * manager any time after reset when a property changes value.
608 * <p>
609 * <strong>Note:</strong> Components should silently ignore properties
610 * that do not affect the operation of the component.
611 *
612 * @param propertyId The property identifier.
613 * @param value The value of the property.
614 *
615 * @throws SAXNotRecognizedException The component should not throw
616 * this exception.
617 * @throws SAXNotSupportedException The component should not throw
618 * this exception.
619 */
620 public void setProperty(String propertyId, Object value) throws XMLConfigurationException {
621 if (propertyId.equals(ROOT_TYPE_DEF)) {
622 if (value == null) {
3020
3021 if (grammar != null) {
3022 currDecl = grammar.getGlobalAttributeDecl(fTempQName.localpart);
3023 }
3024
3025 // if can't find
3026 if (currDecl == null) {
3027 // if strict, report error
3028 if (attrWildcard.fProcessContents == XSWildcardDecl.PC_STRICT) {
3029 reportSchemaError(
3030 "cvc-complex-type.3.2.2",
3031 new Object[] { element.rawname, fTempQName.rawname });
3032 }
3033
3034 // then continue to the next attribute
3035 continue;
3036 } else {
3037 // 5 Let [Definition:] the wild IDs be the set of all attribute information item to which clause 3.2 applied and whose validation resulted in a context-determined declaration of mustFind or no context-determined declaration at all, and whose [local name] and [namespace name] resolve (as defined by QName resolution (Instance) (3.15.4)) to an attribute declaration whose {type definition} is or is derived from ID. Then all of the following must be true:
3038 // 5.1 There must be no more than one item in wild IDs.
3039 if (currDecl.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE
3040 && ((XSSimpleType) currDecl.fType).isIDType()) {
3041 if (wildcardIDName != null) {
3042 reportSchemaError(
3043 "cvc-complex-type.5.1",
3044 new Object[] { element.rawname, currDecl.fName, wildcardIDName });
3045 } else
3046 wildcardIDName = currDecl.fName;
3047 }
3048 }
3049 }
3050
3051 processOneAttribute(element, attributes, index, currDecl, currUse, attrPSVI);
3052 } // end of for (all attributes)
3053
3054 // 5.2 If wild IDs is non-empty, there must not be any attribute uses among the {attribute uses} whose {attribute declaration}'s {type definition} is or is derived from ID.
3055 if (!isSimple && attrGrp.fIDAttrName != null && wildcardIDName != null) {
3056 reportSchemaError(
3057 "cvc-complex-type.5.2",
3058 new Object[] { element.rawname, wildcardIDName, attrGrp.fIDAttrName });
3059 }
3060
4103 fItemValueTypes.add(itemValueType);
4104 }
4105 else if (fItemValueTypesLength++ == 0) {
4106 fItemValueType = itemValueType;
4107 }
4108 else if (!(fItemValueType == itemValueType ||
4109 (fItemValueType != null && fItemValueType.equals(itemValueType)))) {
4110 fUseItemValueTypeVector = true;
4111 if (fItemValueTypes == null) {
4112 fItemValueTypes = new Vector<>(fItemValueTypesLength * 2);
4113 }
4114 for (int i = 1; i < fItemValueTypesLength; ++i) {
4115 fItemValueTypes.add(fItemValueType);
4116 }
4117 fItemValueTypes.add(itemValueType);
4118 }
4119 }
4120
4121 private ShortList getItemValueTypeAt(int index) {
4122 if (fUseItemValueTypeVector) {
4123 return (ShortList) fItemValueTypes.get(index);
4124 }
4125 return fItemValueType;
4126 }
4127
4128 private boolean itemValueTypeContains(ShortList value) {
4129 if (fUseItemValueTypeVector) {
4130 return fItemValueTypes.contains(value);
4131 }
4132 return fItemValueType == value ||
4133 (fItemValueType != null && fItemValueType.equals(value));
4134 }
4135
4136 } // class ValueStoreBase
4137
4138 /**
4139 * Unique value store.
4140 *
4141 * @author Andy Clark, IBM
4142 */
4143 protected class UniqueValueStore extends ValueStoreBase {
4228
4229 /** Constructs a key value store. */
4230 public KeyRefValueStore(KeyRef keyRef, KeyValueStore keyValueStore) {
4231 super(keyRef);
4232 fKeyValueStore = keyValueStore;
4233 } // <init>(KeyRef)
4234
4235 //
4236 // ValueStoreBase methods
4237 //
4238
4239 // end the value Scope; here's where we have to tie
4240 // up keyRef loose ends.
4241 public void endDocumentFragment() {
4242
4243 // do all the necessary management...
4244 super.endDocumentFragment();
4245
4246 // verify references
4247 // get the key store corresponding (if it exists):
4248 fKeyValueStore =
4249 (ValueStoreBase) fValueStoreCache.fGlobalIDConstraintMap.get(
4250 ((KeyRef) fIdentityConstraint).getKey());
4251
4252 if (fKeyValueStore == null) {
4253 // report error
4254 String code = "KeyRefOutOfScope";
4255 String value = fIdentityConstraint.toString();
4256 reportSchemaError(code, new Object[] { value });
4257 return;
4258 }
4259 int errorIndex = fKeyValueStore.contains(this);
4260 if (errorIndex != -1) {
4261 String code = "KeyNotFound";
4262 String values = toString(fValues, errorIndex, fFieldCount);
4263 String element = fIdentityConstraint.getElementName();
4264 String name = fIdentityConstraint.getName();
4265 reportSchemaError(code, new Object[] { name, values, element });
4266 }
4267
4268 } // endDocumentFragment()
4269
|
1 /*
2 * Copyright (c) 2006, 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;
23
555
556 // handlers
557
558 /** Document handler. */
559 protected XMLDocumentHandler fDocumentHandler;
560
561 protected XMLDocumentSource fDocumentSource;
562
563 boolean reportWhitespace = false;
564
565 //
566 // XMLComponent methods
567 //
568
569 /**
570 * Returns a list of feature identifiers that are recognized by
571 * this component. This method may return null if no features
572 * are recognized by this component.
573 */
574 public String[] getRecognizedFeatures() {
575 return RECOGNIZED_FEATURES.clone();
576 } // getRecognizedFeatures():String[]
577
578 /**
579 * Sets the state of a feature. This method is called by the component
580 * manager any time after reset when a feature changes state.
581 * <p>
582 * <strong>Note:</strong> Components should silently ignore features
583 * that do not affect the operation of the component.
584 *
585 * @param featureId The feature identifier.
586 * @param state The state of the feature.
587 *
588 * @throws SAXNotRecognizedException The component should not throw
589 * this exception.
590 * @throws SAXNotSupportedException The component should not throw
591 * this exception.
592 */
593 public void setFeature(String featureId, boolean state) throws XMLConfigurationException {
594 } // setFeature(String,boolean)
595
596 /**
597 * Returns a list of property identifiers that are recognized by
598 * this component. This method may return null if no properties
599 * are recognized by this component.
600 */
601 public String[] getRecognizedProperties() {
602 return RECOGNIZED_PROPERTIES.clone();
603 } // getRecognizedProperties():String[]
604
605 /**
606 * Sets the value of a property. This method is called by the component
607 * manager any time after reset when a property changes value.
608 * <p>
609 * <strong>Note:</strong> Components should silently ignore properties
610 * that do not affect the operation of the component.
611 *
612 * @param propertyId The property identifier.
613 * @param value The value of the property.
614 *
615 * @throws SAXNotRecognizedException The component should not throw
616 * this exception.
617 * @throws SAXNotSupportedException The component should not throw
618 * this exception.
619 */
620 public void setProperty(String propertyId, Object value) throws XMLConfigurationException {
621 if (propertyId.equals(ROOT_TYPE_DEF)) {
622 if (value == null) {
3020
3021 if (grammar != null) {
3022 currDecl = grammar.getGlobalAttributeDecl(fTempQName.localpart);
3023 }
3024
3025 // if can't find
3026 if (currDecl == null) {
3027 // if strict, report error
3028 if (attrWildcard.fProcessContents == XSWildcardDecl.PC_STRICT) {
3029 reportSchemaError(
3030 "cvc-complex-type.3.2.2",
3031 new Object[] { element.rawname, fTempQName.rawname });
3032 }
3033
3034 // then continue to the next attribute
3035 continue;
3036 } else {
3037 // 5 Let [Definition:] the wild IDs be the set of all attribute information item to which clause 3.2 applied and whose validation resulted in a context-determined declaration of mustFind or no context-determined declaration at all, and whose [local name] and [namespace name] resolve (as defined by QName resolution (Instance) (3.15.4)) to an attribute declaration whose {type definition} is or is derived from ID. Then all of the following must be true:
3038 // 5.1 There must be no more than one item in wild IDs.
3039 if (currDecl.fType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE
3040 && (currDecl.fType).isIDType()) {
3041 if (wildcardIDName != null) {
3042 reportSchemaError(
3043 "cvc-complex-type.5.1",
3044 new Object[] { element.rawname, currDecl.fName, wildcardIDName });
3045 } else
3046 wildcardIDName = currDecl.fName;
3047 }
3048 }
3049 }
3050
3051 processOneAttribute(element, attributes, index, currDecl, currUse, attrPSVI);
3052 } // end of for (all attributes)
3053
3054 // 5.2 If wild IDs is non-empty, there must not be any attribute uses among the {attribute uses} whose {attribute declaration}'s {type definition} is or is derived from ID.
3055 if (!isSimple && attrGrp.fIDAttrName != null && wildcardIDName != null) {
3056 reportSchemaError(
3057 "cvc-complex-type.5.2",
3058 new Object[] { element.rawname, wildcardIDName, attrGrp.fIDAttrName });
3059 }
3060
4103 fItemValueTypes.add(itemValueType);
4104 }
4105 else if (fItemValueTypesLength++ == 0) {
4106 fItemValueType = itemValueType;
4107 }
4108 else if (!(fItemValueType == itemValueType ||
4109 (fItemValueType != null && fItemValueType.equals(itemValueType)))) {
4110 fUseItemValueTypeVector = true;
4111 if (fItemValueTypes == null) {
4112 fItemValueTypes = new Vector<>(fItemValueTypesLength * 2);
4113 }
4114 for (int i = 1; i < fItemValueTypesLength; ++i) {
4115 fItemValueTypes.add(fItemValueType);
4116 }
4117 fItemValueTypes.add(itemValueType);
4118 }
4119 }
4120
4121 private ShortList getItemValueTypeAt(int index) {
4122 if (fUseItemValueTypeVector) {
4123 return fItemValueTypes.get(index);
4124 }
4125 return fItemValueType;
4126 }
4127
4128 private boolean itemValueTypeContains(ShortList value) {
4129 if (fUseItemValueTypeVector) {
4130 return fItemValueTypes.contains(value);
4131 }
4132 return fItemValueType == value ||
4133 (fItemValueType != null && fItemValueType.equals(value));
4134 }
4135
4136 } // class ValueStoreBase
4137
4138 /**
4139 * Unique value store.
4140 *
4141 * @author Andy Clark, IBM
4142 */
4143 protected class UniqueValueStore extends ValueStoreBase {
4228
4229 /** Constructs a key value store. */
4230 public KeyRefValueStore(KeyRef keyRef, KeyValueStore keyValueStore) {
4231 super(keyRef);
4232 fKeyValueStore = keyValueStore;
4233 } // <init>(KeyRef)
4234
4235 //
4236 // ValueStoreBase methods
4237 //
4238
4239 // end the value Scope; here's where we have to tie
4240 // up keyRef loose ends.
4241 public void endDocumentFragment() {
4242
4243 // do all the necessary management...
4244 super.endDocumentFragment();
4245
4246 // verify references
4247 // get the key store corresponding (if it exists):
4248 fKeyValueStore = fValueStoreCache.fGlobalIDConstraintMap.get(
4249 ((KeyRef) fIdentityConstraint).getKey());
4250
4251 if (fKeyValueStore == null) {
4252 // report error
4253 String code = "KeyRefOutOfScope";
4254 String value = fIdentityConstraint.toString();
4255 reportSchemaError(code, new Object[] { value });
4256 return;
4257 }
4258 int errorIndex = fKeyValueStore.contains(this);
4259 if (errorIndex != -1) {
4260 String code = "KeyNotFound";
4261 String values = toString(fValues, errorIndex, fFieldCount);
4262 String element = fIdentityConstraint.getElementName();
4263 String name = fIdentityConstraint.getName();
4264 reportSchemaError(code, new Object[] { name, values, element });
4265 }
4266
4267 } // endDocumentFragment()
4268
|