KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > style > XSLComment


1 package net.sf.saxon.style;
2 import net.sf.saxon.expr.Expression;
3 import net.sf.saxon.expr.ExpressionTool;
4 import net.sf.saxon.instruct.Comment;
5 import net.sf.saxon.instruct.Executable;
6 import net.sf.saxon.om.AttributeCollection;
7 import net.sf.saxon.value.StringValue;
8 import net.sf.saxon.trans.XPathException;
9
10 import javax.xml.transform.TransformerConfigurationException JavaDoc;
11
12 /**
13 * An xsl:comment elements in the stylesheet. <br>
14 */

15
16 public final class XSLComment extends XSLStringConstructor {
17
18     public void prepareAttributes() throws XPathException {
19
20         String JavaDoc selectAtt = null;
21
22         AttributeCollection atts = getAttributeList();
23         for (int a=0; a<atts.getLength(); a++) {
24             int nc = atts.getNameCode(a);
25             String JavaDoc f = getNamePool().getClarkName(nc);
26             if (f==StandardNames.SELECT) {
27                 selectAtt = atts.getValue(a).trim();
28             } else {
29                 checkUnknownAttribute(nc);
30             }
31         }
32
33         if (selectAtt!=null) {
34             select = makeExpression(selectAtt);
35         }
36     }
37
38     public void validate() throws XPathException {
39         select = typeCheck("select", select);
40         checkWithinTemplate();
41         super.validate();
42     }
43
44     public Expression compile(Executable exec) throws XPathException {
45         Comment inst = new Comment();
46         compileContent(exec, inst, StringValue.SINGLE_SPACE);
47         //inst.setSeparator(new StringValue(select==null ? "" : " "));
48
ExpressionTool.makeParentReferences(inst);
49         return inst;
50     }
51
52 }
53 //
54
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
55
// you may not use this file except in compliance with the License. You may obtain a copy of the
56
// License at http://www.mozilla.org/MPL/
57
//
58
// Software distributed under the License is distributed on an "AS IS" basis,
59
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
60
// See the License for the specific language governing rights and limitations under the License.
61
//
62
// The Original Code is: all this file.
63
//
64
// The Initial Developer of the Original Code is Michael H. Kay.
65
//
66
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
67
//
68
// Contributor(s): none.
69
//
70
Popular Tags