本文整理汇总了Java中com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl.PARTICLE_ELEMENT属性的典型用法代码示例。如果您正苦于以下问题:Java XSParticleDecl.PARTICLE_ELEMENT属性的具体用法?Java XSParticleDecl.PARTICLE_ELEMENT怎么用?Java XSParticleDecl.PARTICLE_ELEMENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl
的用法示例。
在下文中一共展示了XSParticleDecl.PARTICLE_ELEMENT属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findMatchingDecl
Object findMatchingDecl(QName curElem, SubstitutionGroupHandler subGroupHandler) {
Object matchingDecl = null;
for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
int type = fElemMapType[elemIndex] ;
if (type == XSParticleDecl.PARTICLE_ELEMENT) {
matchingDecl = subGroupHandler.getMatchingElemDecl(curElem, (XSElementDecl)fElemMap[elemIndex]);
if (matchingDecl != null) {
return matchingDecl;
}
}
else if (type == XSParticleDecl.PARTICLE_WILDCARD) {
if(((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri))
return fElemMap[elemIndex];
}
}
return null;
}
示例2: copyNode
private CMNode copyNode(CMNode node) {
int type = node.type();
// for choice or sequence, copy the two subtrees, and combine them
if (type == XSModelGroupImpl.MODELGROUP_CHOICE ||
type == XSModelGroupImpl.MODELGROUP_SEQUENCE) {
XSCMBinOp bin = (XSCMBinOp)node;
node = fNodeFactory.getCMBinOpNode(type, copyNode(bin.getLeft()),
copyNode(bin.getRight()));
}
// for ?+*, copy the subtree, and put it in a new ?+* node
else if (type == XSParticleDecl.PARTICLE_ZERO_OR_MORE ||
type == XSParticleDecl.PARTICLE_ONE_OR_MORE ||
type == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
XSCMUniOp uni = (XSCMUniOp)node;
node = fNodeFactory.getCMUniOpNode(type, copyNode(uni.getChild()));
}
// for element/wildcard (leaf), make a new leaf node,
// with a distinct position
else if (type == XSParticleDecl.PARTICLE_ELEMENT ||
type == XSParticleDecl.PARTICLE_WILDCARD) {
XSCMLeaf leaf = (XSCMLeaf)node;
node = fNodeFactory.getCMLeafNode(leaf.type(), leaf.getLeaf(), leaf.getParticleId(), fLeafCount++);
}
return node;
}
示例3: useRepeatingLeafNodes
private boolean useRepeatingLeafNodes(XSParticleDecl particle) {
int maxOccurs = particle.fMaxOccurs;
int minOccurs = particle.fMinOccurs;
short type = particle.fType;
if (type == XSParticleDecl.PARTICLE_MODELGROUP) {
XSModelGroupImpl group = (XSModelGroupImpl) particle.fValue;
if (minOccurs != 1 || maxOccurs != 1) {
if (group.fParticleCount == 1) {
XSParticleDecl particle2 = (XSParticleDecl) group.fParticles[0];
short type2 = particle2.fType;
return ((type2 == XSParticleDecl.PARTICLE_ELEMENT ||
type2 == XSParticleDecl.PARTICLE_WILDCARD) &&
particle2.fMinOccurs == 1 &&
particle2.fMaxOccurs == 1);
}
return (group.fParticleCount == 0);
}
for (int i = 0; i < group.fParticleCount; ++i) {
if (!useRepeatingLeafNodes(group.fParticles[i])) {
return false;
}
}
}
return true;
}
示例4: postTreeBuildInit
/** Post tree build initialization. */
private void postTreeBuildInit(CMNode nodeCur) throws RuntimeException {
// Set the maximum states on this node
nodeCur.setMaxStates(fLeafCount);
XSCMLeaf leaf = null;
int pos = 0;
// Recurse as required
if (nodeCur.type() == XSParticleDecl.PARTICLE_WILDCARD) {
leaf = (XSCMLeaf)nodeCur;
pos = leaf.getPosition();
fLeafList[pos] = leaf;
fLeafListType[pos] = XSParticleDecl.PARTICLE_WILDCARD;
}
else if ((nodeCur.type() == XSModelGroupImpl.MODELGROUP_CHOICE) ||
(nodeCur.type() == XSModelGroupImpl.MODELGROUP_SEQUENCE)) {
postTreeBuildInit(((XSCMBinOp)nodeCur).getLeft());
postTreeBuildInit(((XSCMBinOp)nodeCur).getRight());
}
else if (nodeCur.type() == XSParticleDecl.PARTICLE_ZERO_OR_MORE ||
nodeCur.type() == XSParticleDecl.PARTICLE_ONE_OR_MORE ||
nodeCur.type() == XSParticleDecl.PARTICLE_ZERO_OR_ONE) {
postTreeBuildInit(((XSCMUniOp)nodeCur).getChild());
}
else if (nodeCur.type() == XSParticleDecl.PARTICLE_ELEMENT) {
// Put this node in the leaf list at the current index if its
// a non-epsilon leaf.
leaf = (XSCMLeaf)nodeCur;
pos = leaf.getPosition();
fLeafList[pos] = leaf;
fLeafListType[pos] = XSParticleDecl.PARTICLE_ELEMENT;
}
else {
throw new RuntimeException("ImplementationMessages.VAL_NIICM");
}
}
示例5: buildSyntaxTree
private CMNode buildSyntaxTree(XSParticleDecl particle, boolean optimize) {
int maxOccurs = particle.fMaxOccurs;
int minOccurs = particle.fMinOccurs;
short type = particle.fType;
CMNode nodeRet = null;
if ((type == XSParticleDecl.PARTICLE_WILDCARD) ||
(type == XSParticleDecl.PARTICLE_ELEMENT)) {
// (task 1) element and wildcard particles should be converted to
// leaf nodes
// REVISIT: Make a clone of the leaf particle, so that if there
// are two references to the same group, we have two different
// leaf particles for the same element or wildcard decl.
// This is useful for checking UPA.
nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
// (task 2) expand occurrence values
nodeRet = expandContentModel(nodeRet, minOccurs, maxOccurs, optimize);
}
else if (type == XSParticleDecl.PARTICLE_MODELGROUP) {
// (task 1,3) convert model groups to binary trees
XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
CMNode temp = null;
// when the model group is a choice of more than one particles, but
// only one of the particle is not empty, (for example
// <choice>
// <sequence/>
// <element name="e"/>
// </choice>
// ) we can't not return that one particle ("e"). instead, we should
// treat such particle as optional ("e?").
// the following boolean variable is true when there are at least
// 2 non-empty children.
boolean twoChildren = false;
for (int i = 0; i < group.fParticleCount; i++) {
// first convert each child to a CM tree
temp = buildSyntaxTree(group.fParticles[i],
optimize &&
minOccurs == 1 && maxOccurs == 1 &&
(group.fCompositor == XSModelGroupImpl.MODELGROUP_SEQUENCE ||
group.fParticleCount == 1));
// then combine them using binary operation
if (temp != null) {
if (nodeRet == null) {
nodeRet = temp;
}
else {
nodeRet = fNodeFactory.getCMBinOpNode(group.fCompositor, nodeRet, temp);
// record the fact that there are at least 2 children
twoChildren = true;
}
}
}
// (task 2) expand occurrence values
if (nodeRet != null) {
// when the group is "choice", there is only one non-empty
// child, and the group had more than one children, we need
// to create a zero-or-one (optional) node for the non-empty
// particle.
if (group.fCompositor == XSModelGroupImpl.MODELGROUP_CHOICE &&
!twoChildren && group.fParticleCount > 1) {
nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
}
nodeRet = expandContentModel(nodeRet, minOccurs, maxOccurs, false);
}
}
return nodeRet;
}
示例6: expandContentModel
private CMNode expandContentModel(CMNode node,
int minOccurs, int maxOccurs, boolean optimize) {
CMNode nodeRet = null;
if (minOccurs==1 && maxOccurs==1) {
nodeRet = node;
}
else if (minOccurs==0 && maxOccurs==1) {
//zero or one
nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, node);
}
else if (minOccurs == 0 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
//zero or more
nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_MORE, node);
}
else if (minOccurs == 1 && maxOccurs==SchemaSymbols.OCCURRENCE_UNBOUNDED) {
//one or more
nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
}
else if (optimize && node.type() == XSParticleDecl.PARTICLE_ELEMENT ||
node.type() == XSParticleDecl.PARTICLE_WILDCARD) {
// Only for elements and wildcards, subsume e{n,m} and e{n,unbounded} to e*
// or e+ and, once the DFA reaches a final state, check if the actual number
// of elements is between minOccurs and maxOccurs. This new algorithm runs
// in constant space.
// TODO: What is the impact of this optimization on the PSVI?
nodeRet = fNodeFactory.getCMUniOpNode(
minOccurs == 0 ? XSParticleDecl.PARTICLE_ZERO_OR_MORE
: XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
nodeRet.setUserData(new int[] { minOccurs, maxOccurs });
}
else if (maxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED) {
// => a,a,..,a+
// create a+ node first, then put minOccurs-1 a's in front of it
// for the first time "node" is used, we don't need to make a copy
// and for other references to node, we make copies
nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ONE_OR_MORE, node);
// (task 4) we need to call copyNode here, so that we append
// an entire new copy of the node (a subtree). this is to ensure
// all leaf nodes have distinct position
// we know that minOccurs > 1
nodeRet = fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
multiNodes(node, minOccurs-1, true), nodeRet);
}
else {
// {n,m} => a,a,a,...(a),(a),...
// first n a's, then m-n a?'s.
// copyNode is called, for the same reason as above
if (minOccurs > 0) {
nodeRet = multiNodes(node, minOccurs, false);
}
if (maxOccurs > minOccurs) {
node = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, node);
if (nodeRet == null) {
nodeRet = multiNodes(node, maxOccurs-minOccurs, false);
}
else {
nodeRet = fNodeFactory.getCMBinOpNode(XSModelGroupImpl.MODELGROUP_SEQUENCE,
nodeRet, multiNodes(node, maxOccurs-minOccurs, true));
}
}
}
return nodeRet;
}
示例7: buildCompactSyntaxTree
private CMNode buildCompactSyntaxTree(XSParticleDecl particle) {
int maxOccurs = particle.fMaxOccurs;
int minOccurs = particle.fMinOccurs;
short type = particle.fType;
CMNode nodeRet = null;
if ((type == XSParticleDecl.PARTICLE_WILDCARD) ||
(type == XSParticleDecl.PARTICLE_ELEMENT)) {
return buildCompactSyntaxTree2(particle, minOccurs, maxOccurs);
}
else if (type == XSParticleDecl.PARTICLE_MODELGROUP) {
XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
if (group.fParticleCount == 1 && (minOccurs != 1 || maxOccurs != 1)) {
return buildCompactSyntaxTree2(group.fParticles[0], minOccurs, maxOccurs);
}
else {
CMNode temp = null;
// when the model group is a choice of more than one particles, but
// only one of the particle is not empty, (for example
// <choice>
// <sequence/>
// <element name="e"/>
// </choice>
// ) we can't not return that one particle ("e"). instead, we should
// treat such particle as optional ("e?").
// the following int variable keeps track of the number of non-empty children
int count = 0;
for (int i = 0; i < group.fParticleCount; i++) {
// first convert each child to a CM tree
temp = buildCompactSyntaxTree(group.fParticles[i]);
// then combine them using binary operation
if (temp != null) {
++count;
if (nodeRet == null) {
nodeRet = temp;
}
else {
nodeRet = fNodeFactory.getCMBinOpNode(group.fCompositor, nodeRet, temp);
}
}
}
if (nodeRet != null) {
// when the group is "choice" and the group has one or more empty children,
// we need to create a zero-or-one (optional) node for the non-empty particles.
if (group.fCompositor == XSModelGroupImpl.MODELGROUP_CHOICE && count < group.fParticleCount) {
nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
}
}
}
}
return nodeRet;
}