Package com.sun.msv.util

Examples of com.sun.msv.util.StartTagInfo


       
        context.getNamespaceContext().startElement();
       
        stack.push(acceptor);
       
        StartTagInfo sti = new StartTagInfo(uri,local,local,emptyAttributes,this);
       
        // we pass in an empty attributes, as there is just no way for us to
        // properly re-construct attributes. Fortunately, I know MSV is not using
        // attribute values, so this would work, but nevertheless this code is
        // ugly. This is one of the problems of the "middle" approach.
View Full Code Here


//        } else
//            atts = emptyAttributes;
           
       
        // feed a dummy element to the acceptor.
        StartTagInfo sti = new StartTagInfo(
            DUMMY_ELEMENT_NS,
            intfName,
            intfName/*just pass the local name as QName.*/,
            emptyAttributes,
            this );
View Full Code Here

    // if an error was found, stop processing.
    if( hadError return exp;
   
    // check Tahiti attributes.
   
    final StartTagInfo tag = state.getStartTag();
    String role = tag.getAttribute(TahitiNamespace,"role");
   
    if( role==null ) {
      // there is no markup.
     
      // insert an ClassItem if this is the <element> tag.
      // some of those temporarily added ClassItems will be removed
      // in the final wrap up.
      if( tag.localName.equals("element") ) {
//      if( exp instanceof ElementExp ) {
/*
        ElementExp eexp = (ElementExp)exp;
        // add a ClassItem between the ElementExp and the content model.
        ClassItem t = annGrammar.createClassItem( decideName(state,exp,"class"), eexp.contentModel );
        eexp.contentModel = t;
       
        t.isTemporary = true;  // this flag indicates that this class item is a temporary one.
       
        return eexp;
*/
        // to make marshalling easy, ClassItem is generated above the ElementExp
       
        // calculate the unique name to avoid name conflicts.
        String baseName = decideName(state,exp,"class");
        if( annGrammar.classes.containsKey(baseName) ) {
          int cnt = 2;
          while( annGrammar.classes.containsKey(baseName+cnt) )
            cnt++;
          baseName += cnt;
        }
       
        ClassItem t = annGrammar.createClassItem( baseName, exp );
        t.isTemporary = true;
        return t;
      } else {
        // if this element has the t:name attribute, store that
        // information by using a ReferenceExp. This information
        // might be useful to various annotators.
//        String name = tag.getAttribute(TahitiNamespace,"name");
//        if(name!=null)  exp = new ReferenceExp( name, exp );
      }
     
      return exp;  // the "role" attribute is not present.
    }
   
   
    OtherExp roleExp;
   
    if( role.equals("none") ) {
      // do nothing. this will prevent automatic ClassItem insertion.
      return exp;
    } else
    if( role.equals("superClass") ) {
      roleExp = new SuperClassItem();
    } else
    if( role.equals("class") ) {
      /*
      removes silly use of temporary ClassItem.
      Consider the following grammar fragment:
      <define name="foo" t:role="class">
        <element name="foo">
          ...
        </element>
      </define>
     
      Since there is no tahiti markup for <element> element, a temporary ClassItem
      is inserted. Immediately after that, a <define> element is processed, and
      a new ClassItem is inserted.
     
      The following code is a quick hack to prevent this situation by removing
      temporary ClassItem if it is the immediate child of the user-defined class.
       */
      /*
        We changed the code and now temporary class items are generated
        *above* elements. So now this code is unnecessary.
      */
/* TODO:
  we have to think in much broader view.
  This could be done as a part of temporary class item removal.
  Otherwise, we have to implement this mechanism to every reader.
 
  Also, this particular situation would interact with the combine attribute.
*/     
/*      if( (exp instanceof ClassItem) && ((ClassItem)exp).isTemporary )
        exp = ((ClassItem)exp).exp;
      if( exp.getClass()==ReferenceExp.class ) {
        ReferenceExp rexp = (ReferenceExp)exp;
        if( (rexp.exp instanceof ClassItem) && ((ClassItem)rexp.exp).isTemporary )
          rexp.exp = ((ClassItem)rexp.exp).exp;
      }
*/     
      roleExp = annGrammar.createClassItem(decideName(state,exp,role),null);
    } else
    if( role.equals("field") ) {
      FieldItem fi = new FieldItem(decideName(state,exp,role));
      roleExp = fi;
     
      // read the additional configuration.
      String collection = tag.getAttribute(TahitiNamespace,"collection");
      if(collection!=null) {
        fi.collectionType = fi.collectionType.parse(collection);
        if(fi.collectionType==null)
          reportError( ERR_INVALID_COLLECTION_TYPE, collection );
      }
      String access = tag.getAttribute(TahitiNamespace,"access");
      if(access!=null) {
        fi.accessModifier = fi.accessModifier.parse(access);
        if(fi.accessModifier==null)
          reportError( ERR_INVALID_ACCESS_MODIFIER, access );
      }
      String method = tag.getAttribute(TahitiNamespace,"method");
      if(method!=null) {
        fi.accessor = fi.accessor.parse(method);
        if(fi.accessModifier==null)
          reportError( ERR_INVALID_ACCESSOR, method );
      }
View Full Code Here

   * @param role
   *    the role of this expression. One of "field","interface", and "class".
   */
  protected String decideName( ExpressionState state, Expression exp, String role ) {
   
    final StartTagInfo tag = state.getStartTag();
 
    String name = tag.getAttribute(TahitiNamespace,"name");
    // if we have t:name attribute, use it.
    if(name==null) {
   
      // if the current tag has the name attribute, use it.
      // this is the case of <define/>,<ref/>, and sometimes
      // <element/> and <attribute/>
      name = tag.getAttribute("name");
      if(name!=nullname = NameUtil.xmlNameToJavaName(role,name);
    }
   
    if(name==null) {
      // otherwise, sniff the name.
View Full Code Here

            // some required attributes are missing.
            // report a validation error
            // Note that we don't know which property of this object
            // causes this error.
            StringRef ref = new StringRef();
            StartTagInfo sti = new StartTagInfo(
                currentElementUri,currentElementLocalName,currentElementLocalName,
                emptyAttributes,this);
            acceptor.onEndAttributes( sti, ref );
            context.reportEvent(target,ref.str);
        }
View Full Code Here

       
        context.getNamespaceContext().startElement();
       
        stack.push(acceptor);
       
        StartTagInfo sti = new StartTagInfo(uri,local,local,emptyAttributes,this);
       
        // we pass in an empty attributes, as there is just no way for us to
        // properly re-construct attributes. Fortunately, I know MSV is not using
        // attribute values, so this would work, but nevertheless this code is
        // ugly. This is one of the problems of the "middle" approach.
View Full Code Here

//        } else
//            atts = emptyAttributes;
           
       
        // feed a dummy element to the acceptor.
        StartTagInfo sti = new StartTagInfo(
            DUMMY_ELEMENT_NS,
            intfName,
            intfName/*just pass the local name as QName.*/,
            emptyAttributes,
            this );
View Full Code Here

    protected boolean isGrammarElement( StartTagInfo tag ) {
        return reader.isGrammarElement(tag);
    }
   
    public void startElement( String namespaceURI, String localName, String qName, Attributes atts ) {
        final StartTagInfo tag = new StartTagInfo(
            namespaceURI,localName,qName,new AttributesImpl(atts));
        // we have to copy Attributes, otherwise it will be mutated by SAX parser
           
        if( isGrammarElement(tag) ) {
            // this is a grammar element.
View Full Code Here

    protected abstract XSDatatypeExp makeType() throws DatatypeException;


    public final void startElement( String namespaceURI, String localName, String qName, Attributes atts )
    {// within the island of XSD, foreign namespaces are prohibited.
        final StartTagInfo tag = new StartTagInfo(
            namespaceURI,localName,qName,new AttributesImpl(atts));
        // we have to copy Attributes, otherwise it will be mutated by SAX parser
           
        State nextState = createChildState(tag);
        if(nextState!=null) {
View Full Code Here

TOP

Related Classes of com.sun.msv.util.StartTagInfo

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.