Package com.sun.msv.grammar

Examples of com.sun.msv.grammar.Expression


   * extract PuzzlePieces out of a XML schema</p>
   */
  @Test
  public void testMSVExpressionTree() {
    try {
      Expression odf10Root = OdfHelper.loadSchemaODF10();
      String odf10Dump = MSVExpressionIterator.dumpMSVExpressionTree(odf10Root);
      LOG.info("Writing MSV RelaxNG tree into file: " + OUTPUT_DUMP_ODF10);
      PrintWriter out0 = new PrintWriter(new FileWriter(OUTPUT_DUMP_ODF10));
      out0.print(odf10Dump);
      out0.close();

      Expression odf11Root = OdfHelper.loadSchemaODF11();
      String odf11Dump = MSVExpressionIterator.dumpMSVExpressionTree(odf11Root);
      LOG.info("Writing MSV RelaxNG tree into file: " + OUTPUT_DUMP_ODF11);
      PrintWriter out1 = new PrintWriter(new FileWriter(OUTPUT_DUMP_ODF11));
      out1.print(odf11Dump);
      out1.close();

      Expression odf12Root = OdfHelper.loadSchemaODF12();
      String odf12Dump = MSVExpressionIterator.dumpMSVExpressionTree(odf12Root);
      LOG.info("Writing MSV RelaxNG tree into file: " + OUTPUT_DUMP_ODF12);
      PrintWriter out2 = new PrintWriter(new FileWriter(OUTPUT_DUMP_ODF12));
      out2.print(odf12Dump);
      out2.close();
View Full Code Here


   */
  public static Expression loadSchema(File rngFile) throws Exception {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);
    // Parsing the Schema with MSV
    Expression root = RELAXNGReader.parse(
        rngFile.getAbsolutePath(),
        factory,
        new com.sun.msv.reader.util.IgnoreController()).getTopLevel();


View Full Code Here

    }
   
    private static Grammar deserialize( InputStream is ) {
        try {
            ObjectInputStream ois = new ObjectInputStream( is );
            final Expression exp = (Expression)ois.readObject();
            final ExpressionPool pool = (ExpressionPool)ois.readObject();
            ois.close();
       
            return new Grammar() {
                public Expression getTopLevel() { return exp; }
View Full Code Here

     */
    private Grammar union( Grammar g1, Grammar g2 ) {
        // either g1.getPool() or g2.getPool() is OK.
        // this is just a metter of performance problem.
        final ExpressionPool pool = g1.getPool();
        final Expression top = pool.createChoice(g1.getTopLevel(),g2.getTopLevel());
       
        return new Grammar() {
            public ExpressionPool getPool() {
                return pool;
            }
View Full Code Here


    public void onAttribute( AttributeExp exp ) {
        if(!(exp.nameClass instanceof SimpleNameClass ))    return;
       
        Expression body = exp.exp.getExpandedExp(reader.pool);
        if(!(body instanceof DataExp ))                    return;
       
        SimpleNameClass snc = (SimpleNameClass)exp.nameClass;
        if(!snc.namespaceURI.equals(""))    return;
       
View Full Code Here

        String refQName = startTag.getAttribute("ref");
        if( refQName==null )
            // child expressions are expected. (although it's optional)
            return Expression.epsilon;

        Expression exp = reader.resolveQNameRef(
            startTag, "ref",
            new XMLSchemaReader.RefResolver() {
                public ReferenceContainer get( XMLSchemaSchema g ) {
                    return g.attributeGroups;
                }
View Full Code Here

                    startTag.qName, "ref" );
                return Expression.epsilon;
            }
           
            // this tag has @ref.
            Expression exp = reader.resolveQNameRef(
                startTag, "ref",
                new XMLSchemaReader.RefResolver() {
                    public ReferenceContainer get( XMLSchemaSchema g ) {
                        return g.attributeDecls;
                    }
View Full Code Here

        final String fixed = startTag.getAttribute("fixed");
        final String name = startTag.getAttribute("name");
        final String use = startTag.getAttribute("use");


        Expression exp;
       
        if( startTag.containsAttribute("ref") ) {
            if( fixed!=null )
                reader.reportWarning( XMLSchemaReader.ERR_UNIMPLEMENTED_FEATURE,
                    "<attribute> element with both 'ref' and 'fixed' attributes" );
View Full Code Here

* @author <a href="mailto:kohsuke.kawaguchi@eng.sun.com">Kohsuke KAWAGUCHI</a>
*/
public class CompAttributeState extends AttributeState {
    protected Expression annealExpression( Expression contentModel ) {
       
        final Expression exp = super.annealExpression(contentModel);
       
        String defaultValue = startTag.getAttribute(
            RELAXNGCompReader.AnnotationNamespace, "defaultValue" );
        if(defaultValue!=null && (exp instanceof AttributeExp)) {
//            if(!nameClass instanceof SimpleNameClass)
View Full Code Here

                // recover by ignoring this attribute.
                // since attributes are combined by sequence, so epsilon is appropriate.
                return Expression.epsilon;
            }
           
            Expression exp = reader.pool.createAttribute(
                new SimpleNameClass("",name),
                incubator.derive(null,null) );
           
            // unless required attribute is specified, it is considered optional
            if(! "true".equals(required) )
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.