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