//
// Check that the left value is not -1, since any content model
// with PCDATA should be MIXED, so we should not have gotten here.
//
if (specNode.value == -1)
throw new CMException(ImplementationMessages.VAL_NPCD);
if (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
{
//
// Its a single leaf, so its an 'a' type of content model, i.e.
// just one instance of one element. That one is definitely a
// simple content model.
//
return new SimpleContentModel(specNode.value, -1, specNode.type);
}
else if ((specNode.type == XMLContentSpecNode.CONTENTSPECNODE_CHOICE)
|| (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_SEQ))
{
//
// Lets see if both of the children are leafs. If so, then it
// it has to be a simple content model
//
XMLContentSpecNode specLeft = new XMLContentSpecNode();
XMLContentSpecNode specRight = new XMLContentSpecNode();
fElementDeclPool.getContentSpecNode(specNode.value, specLeft);
fElementDeclPool.getContentSpecNode(specNode.otherValue, specRight);
if ((specLeft.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
&& (specRight.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF))
{
//
// Its a simple choice or sequence, so we can do a simple
// content model for it.
//
return new SimpleContentModel
(
specLeft.value
, specRight.value
, specNode.type
);
}
}
else if ((specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_ONE)
|| (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_MORE)
|| (specNode.type == XMLContentSpecNode.CONTENTSPECNODE_ONE_OR_MORE))
{
//
// Its a repetition, so see if its one child is a leaf. If so
// its a repetition of a single element, so we can do a simple
// content model for that.
//
XMLContentSpecNode specLeft = new XMLContentSpecNode();
fElementDeclPool.getContentSpecNode(specNode.value, specLeft);
if (specLeft.type == XMLContentSpecNode.CONTENTSPECNODE_LEAF)
{
//
// It is, so we can create a simple content model here that
// will check for this repetition. We pass -1 for the unused
// right node.
//
return new SimpleContentModel(specLeft.value, -1, specNode.type);
}
}
else
{
throw new CMException(ImplementationMessages.VAL_CST);
}
//
// Its not a simple content model, so here we have to create a DFA
// for this element. So we create a DFAContentModel object. He