Package com.sun.msv.grammar

Examples of com.sun.msv.grammar.Expression


    Iterator<PuzzlePiece> iter = elements.iterator();
    while (iter.hasNext()) {
      PuzzlePiece def = iter.next();
      MSVExpressionIterator childFinder = new MSVExpressionIterator(def.getExpression(), NameClassAndExpression.class, MSVExpressionIterator.DIRECT_CHILDREN_ONLY);
      while (childFinder.hasNext()) {
        Expression child_exp = childFinder.next();
        //2DO: IS CHILDEXPR BEREITS VORGEKOMMEN
        // OR UNIQUE NEXT
        List<PuzzlePiece> child_defs = null;
        PuzzlePieceSet whereToAdd = null;
        if (child_exp instanceof ElementExp) {
View Full Code Here


    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);
    // Parsing the Schema with MSV
    String absolutePath = rngFile.getAbsolutePath();
    com.sun.msv.reader.util.IgnoreController ignoreController = new com.sun.msv.reader.util.IgnoreController();
    Expression root = RELAXNGReader.parse(absolutePath, factory, ignoreController).getTopLevel();


    if (root == null) {
      throw new Exception("Schema could not be parsed.");
    }
View Full Code Here

    private void registerChildrenMaxCardinalities(List<List<Expression>> waysToChildren) {
        Map<Expression, Boolean> multiples = new HashMap<Expression, Boolean>();        // Cardinality (the opposite of isSingleton): true=N, false=1
        Map<Expression, List<Expression>> paths = new HashMap<Expression, List<Expression>>();

        for (List<Expression> way : waysToChildren) {
            Expression childexp = way.get(way.size()-1);

            Boolean newCardinality = new Boolean(false);                        // Cardinality (the opposite of isSingleton): true=N, false=1
            for (Expression step : way) {
                if (step instanceof OneOrMoreExp) {
                    newCardinality = new Boolean(true);
View Full Code Here

     *      ElementExp parent -> [all Expressions but ElementExp or AttributeExp]* -> AttributeExp child
     * Since we use recursion we cannot make sure a path ends with an ElementExp or AttributeExp.
     */
    private static void buildPaths(MSVExpressionVisitorChildren visitor, List<List<Expression>> paths) {
        List<Expression> waytoresearch = paths.get(paths.size() - 1);
        Expression endpoint = waytoresearch.get(waytoresearch.size() - 1);
        List<Expression> children = (List<Expression>) endpoint.visit(visitor);

        if (children.size() == 1) {
            Expression child = children.get(0);
            waytoresearch.add(child);
            if (!(child instanceof ElementExp) && !(child instanceof AttributeExp)) {
                buildPaths(visitor, paths);
            }
        } else if (children.size() > 1) {
View Full Code Here

    private static Expression parseOdfSchema(File rngFile) throws Exception {
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware(true);

        Expression root = RELAXNGReader.parse(
                rngFile.getAbsolutePath(),
                factory,
                new com.sun.msv.reader.util.IgnoreController()).getTopLevel();

        if (root == null) {
View Full Code Here

        HashSet<Expression> visitedChoices = new HashSet<Expression>();

        for (List<Expression> path : twins) {
            for (int s=0; s<path.size(); s++) {
                Expression step = path.get(s);
                if (step instanceof ChoiceExp && !visitedChoices.contains(step)) {
                    visitedChoices.add(step);

                    // If other twin paths share the same choice...
                    List<List<Expression>> choiceInPaths = new ArrayList<List<Expression>>(mContainedInPaths.get(step));
View Full Code Here

        }
        return root;
    }

    public static void main(String[] args) throws Exception {
        Expression root = parseOdfSchema(new File(ODF_RESOURCE_DIR + File.separator + OdfHelper.ODF12_RNG_FILE_NAME));
        PuzzlePieceSet elements = new PuzzlePieceSet();
        PuzzlePieceSet attributes = new PuzzlePieceSet();
        PuzzlePiece.extractPuzzlePieces(root, elements, attributes);
        Map<String, SortedSet<PuzzlePiece>> nameToDefinition = createDefinitionMap(new TreeSet<PuzzlePiece>(elements));
View Full Code Here

import com.sun.tahiti.grammar.ClassItem;

public class TGroupState extends GroupState {

  protected Expression annealExpression(Expression contentType) {
    final Expression body = super.annealExpression(contentType);
    final TXMLSchemaReader reader = (TXMLSchemaReader)this.reader;
   
    if(!isGlobal())
      // if it's not a global one, then it is a reference to a model group.
      // So do nothing.
View Full Code Here

import com.sun.tahiti.reader.TahitiGrammarReader;

public class TComplexTypeDeclState extends ComplexTypeDeclState {
 
  protected Expression annealExpression(Expression contentType) {
    final Expression body = super.annealExpression(contentType);
    final TXMLSchemaReader reader = (TXMLSchemaReader)this.reader;
   
    if( !isGlobal() )
      // we assign ClassItem only when the complex type is a global one.
      return body;
View Full Code Here

    writer.start("parserTable");
    int no = 0;
   
    Iterator itr = impl.keySet().iterator();
    while( itr.hasNext() ) {
      Expression nonTerm = (Expression)itr.next();
      Map t2r = (Map)impl.get(nonTerm);
     
      writer.start("action",
        new String[]{"stackTop",symbolizer.getId(nonTerm)});
     
      Rule defaultAction=null;
      {
        Set defaultActionSet = (Set)t2r.get(Expression.epsilon);
        if(defaultActionSet!=null) {
          if(defaultActionSet.size()>1)
            // only one default action is possible
            throw new Error();
          if(defaultActionSet.size()==1)
            defaultAction = (Rule)defaultActionSet.toArray()[0];
        }
      }
     
     
      Iterator jtr = t2r.keySet().iterator();
      while( jtr.hasNext() ) {
        Expression term = (Expression)jtr.next();
        // applicable rules.
        Rule[] rules = (Rule[])((Set)t2r.get(term)).toArray(new Rule[0]);
       
        if( rules.length==1 && rules[0]==defaultAction && term!=Expression.epsilon )
          continue// this token statement can be absorbed by the "otherwise" clause.
View Full Code Here

TOP

Related Classes of com.sun.msv.grammar.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.