< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeSet.java

Print this page


   1 /*
   2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Oct 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *     http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 /*
  22  * $Id: AttributeSet.java,v 1.5 2005/09/28 13:48:04 pvedula Exp $
  23  */


  98         if ((_name == null) || (_name.equals(EMPTYSTRING))) {
  99             ErrorMsg msg = new ErrorMsg(ErrorMsg.UNNAMED_ATTRIBSET_ERR, this);
 100             parser.reportError(Constants.ERROR, msg);
 101         }
 102 
 103         // Get any included attribute sets (similar to inheritance...)
 104         final String useSets = getAttribute("use-attribute-sets");
 105         if (useSets.length() > 0) {
 106             if (!Util.isValidQNames(useSets)) {
 107                 ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, useSets, this);
 108                 parser.reportError(Constants.ERROR, err);
 109             }
 110             _useSets = new UseAttributeSets(useSets, parser);
 111         }
 112 
 113         // Parse the contents of this node. All child elements must be
 114         // <xsl:attribute> elements. Other elements cause an error.
 115         final List<SyntaxTreeNode> contents = getContents();
 116         final int count = contents.size();
 117         for (int i=0; i<count; i++) {
 118             SyntaxTreeNode child = (SyntaxTreeNode)contents.get(i);
 119             if (child instanceof XslAttribute) {
 120                 parser.getSymbolTable().setCurrentNode(child);
 121                 child.parseContents(parser);
 122             }
 123             else if (child instanceof Text) {
 124                 // ignore
 125             }
 126             else {
 127                 ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_CHILD_ERR, this);
 128                 parser.reportError(Constants.ERROR, msg);
 129             }
 130         }
 131 
 132         // Point the symbol table back at us...
 133         parser.getSymbolTable().setCurrentNode(this);
 134     }
 135 
 136     /**
 137      * Type check the contents of this element
 138      */


 167             final InstructionList il = methodGen.getInstructionList();
 168             final String methodName = _mergeSet.getMethodName();
 169 
 170             il.append(classGen.loadTranslet());
 171             il.append(methodGen.loadDOM());
 172             il.append(methodGen.loadIterator());
 173             il.append(methodGen.loadHandler());
 174             il.append(methodGen.loadCurrentNode());
 175             final int method = cpg.addMethodref(classGen.getClassName(),
 176                                                 methodName, ATTR_SET_SIG);
 177             il.append(new INVOKESPECIAL(method));
 178         }
 179 
 180         // Translate other used attribute sets first, as local attributes
 181         // take precedence (last attributes overrides first)
 182         if (_useSets != null) _useSets.translate(classGen, methodGen);
 183 
 184         // Translate all local attributes
 185         final Iterator<SyntaxTreeNode> attributes = elements();
 186         while (attributes.hasNext()) {
 187             SyntaxTreeNode element = (SyntaxTreeNode)attributes.next();
 188             if (element instanceof XslAttribute) {
 189                 final XslAttribute attribute = (XslAttribute)element;
 190                 attribute.translate(classGen, methodGen);
 191             }
 192         }
 193         final InstructionList il = methodGen.getInstructionList();
 194         il.append(RETURN);
 195 
 196         classGen.addMethod(methodGen);
 197     }
 198 
 199     public String toString() {
 200         StringBuffer buf = new StringBuffer("attribute-set: ");
 201         // Translate all local attributes
 202         final Iterator<SyntaxTreeNode> attributes = elements();
 203         while (attributes.hasNext()) {
 204             final XslAttribute attribute =
 205                 (XslAttribute)attributes.next();
 206             buf.append(attribute);
 207         }
   1 /*
   2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Nov 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *     http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 /*
  22  * $Id: AttributeSet.java,v 1.5 2005/09/28 13:48:04 pvedula Exp $
  23  */


  98         if ((_name == null) || (_name.equals(EMPTYSTRING))) {
  99             ErrorMsg msg = new ErrorMsg(ErrorMsg.UNNAMED_ATTRIBSET_ERR, this);
 100             parser.reportError(Constants.ERROR, msg);
 101         }
 102 
 103         // Get any included attribute sets (similar to inheritance...)
 104         final String useSets = getAttribute("use-attribute-sets");
 105         if (useSets.length() > 0) {
 106             if (!Util.isValidQNames(useSets)) {
 107                 ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, useSets, this);
 108                 parser.reportError(Constants.ERROR, err);
 109             }
 110             _useSets = new UseAttributeSets(useSets, parser);
 111         }
 112 
 113         // Parse the contents of this node. All child elements must be
 114         // <xsl:attribute> elements. Other elements cause an error.
 115         final List<SyntaxTreeNode> contents = getContents();
 116         final int count = contents.size();
 117         for (int i=0; i<count; i++) {
 118             SyntaxTreeNode child = contents.get(i);
 119             if (child instanceof XslAttribute) {
 120                 parser.getSymbolTable().setCurrentNode(child);
 121                 child.parseContents(parser);
 122             }
 123             else if (child instanceof Text) {
 124                 // ignore
 125             }
 126             else {
 127                 ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_CHILD_ERR, this);
 128                 parser.reportError(Constants.ERROR, msg);
 129             }
 130         }
 131 
 132         // Point the symbol table back at us...
 133         parser.getSymbolTable().setCurrentNode(this);
 134     }
 135 
 136     /**
 137      * Type check the contents of this element
 138      */


 167             final InstructionList il = methodGen.getInstructionList();
 168             final String methodName = _mergeSet.getMethodName();
 169 
 170             il.append(classGen.loadTranslet());
 171             il.append(methodGen.loadDOM());
 172             il.append(methodGen.loadIterator());
 173             il.append(methodGen.loadHandler());
 174             il.append(methodGen.loadCurrentNode());
 175             final int method = cpg.addMethodref(classGen.getClassName(),
 176                                                 methodName, ATTR_SET_SIG);
 177             il.append(new INVOKESPECIAL(method));
 178         }
 179 
 180         // Translate other used attribute sets first, as local attributes
 181         // take precedence (last attributes overrides first)
 182         if (_useSets != null) _useSets.translate(classGen, methodGen);
 183 
 184         // Translate all local attributes
 185         final Iterator<SyntaxTreeNode> attributes = elements();
 186         while (attributes.hasNext()) {
 187             SyntaxTreeNode element = attributes.next();
 188             if (element instanceof XslAttribute) {
 189                 final XslAttribute attribute = (XslAttribute)element;
 190                 attribute.translate(classGen, methodGen);
 191             }
 192         }
 193         final InstructionList il = methodGen.getInstructionList();
 194         il.append(RETURN);
 195 
 196         classGen.addMethod(methodGen);
 197     }
 198 
 199     public String toString() {
 200         StringBuffer buf = new StringBuffer("attribute-set: ");
 201         // Translate all local attributes
 202         final Iterator<SyntaxTreeNode> attributes = elements();
 203         while (attributes.hasNext()) {
 204             final XslAttribute attribute =
 205                 (XslAttribute)attributes.next();
 206             buf.append(attribute);
 207         }
< prev index next >