1 /*
2 * Copyright (c) 2006, 2009, 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.models;
22
440 else {
441 nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
442 }
443 }
444 return nodeRet;
445 }
446
447 // This method checks if this particle can be transformed into a compact syntax
448 // tree containing compound leaf nodes which carry occurence information. Currently
449 // it returns true if each model group has minOccurs/maxOccurs == 1 or
450 // contains only one element/wildcard particle with minOccurs/maxOccurs == 1.
451 private boolean useRepeatingLeafNodes(XSParticleDecl particle) {
452 int maxOccurs = particle.fMaxOccurs;
453 int minOccurs = particle.fMinOccurs;
454 short type = particle.fType;
455
456 if (type == XSParticleDecl.PARTICLE_MODELGROUP) {
457 XSModelGroupImpl group = (XSModelGroupImpl) particle.fValue;
458 if (minOccurs != 1 || maxOccurs != 1) {
459 if (group.fParticleCount == 1) {
460 XSParticleDecl particle2 = (XSParticleDecl) group.fParticles[0];
461 short type2 = particle2.fType;
462 return ((type2 == XSParticleDecl.PARTICLE_ELEMENT ||
463 type2 == XSParticleDecl.PARTICLE_WILDCARD) &&
464 particle2.fMinOccurs == 1 &&
465 particle2.fMaxOccurs == 1);
466 }
467 return (group.fParticleCount == 0);
468 }
469 for (int i = 0; i < group.fParticleCount; ++i) {
470 if (!useRepeatingLeafNodes(group.fParticles[i])) {
471 return false;
472 }
473 }
474 }
475 return true;
476 }
477 }
|
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.models;
23
441 else {
442 nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, nodeRet);
443 }
444 }
445 return nodeRet;
446 }
447
448 // This method checks if this particle can be transformed into a compact syntax
449 // tree containing compound leaf nodes which carry occurence information. Currently
450 // it returns true if each model group has minOccurs/maxOccurs == 1 or
451 // contains only one element/wildcard particle with minOccurs/maxOccurs == 1.
452 private boolean useRepeatingLeafNodes(XSParticleDecl particle) {
453 int maxOccurs = particle.fMaxOccurs;
454 int minOccurs = particle.fMinOccurs;
455 short type = particle.fType;
456
457 if (type == XSParticleDecl.PARTICLE_MODELGROUP) {
458 XSModelGroupImpl group = (XSModelGroupImpl) particle.fValue;
459 if (minOccurs != 1 || maxOccurs != 1) {
460 if (group.fParticleCount == 1) {
461 XSParticleDecl particle2 = group.fParticles[0];
462 short type2 = particle2.fType;
463 return ((type2 == XSParticleDecl.PARTICLE_ELEMENT ||
464 type2 == XSParticleDecl.PARTICLE_WILDCARD) &&
465 particle2.fMinOccurs == 1 &&
466 particle2.fMaxOccurs == 1);
467 }
468 return (group.fParticleCount == 0);
469 }
470 for (int i = 0; i < group.fParticleCount; ++i) {
471 if (!useRepeatingLeafNodes(group.fParticles[i])) {
472 return false;
473 }
474 }
475 }
476 return true;
477 }
478 }
|