KickJava   Java API By Example, From Geeks To Geeks.

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


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.Executable;
5 import net.sf.saxon.instruct.ProcessingInstruction;
6 import net.sf.saxon.om.AttributeCollectionImpl;
7 import net.sf.saxon.om.AttributeCollection;
8 import net.sf.saxon.value.StringValue;
9 import net.sf.saxon.trans.XPathException;
10
11 import javax.xml.transform.TransformerConfigurationException JavaDoc;
12
13 /**
14 * An xsl:processing-instruction element in the stylesheet.
15 */

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