KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > style > XSLComment


1 package com.icl.saxon.style;
2 import com.icl.saxon.tree.AttributeCollection;
3 import com.icl.saxon.Context;
4
5
6 import com.icl.saxon.output.Outputter;
7 import javax.xml.transform.TransformerException JavaDoc;
8 import javax.xml.transform.TransformerConfigurationException JavaDoc;
9 //import java.util.*;
10

11 /**
12 * An xsl:comment elements in the stylesheet.<BR>
13 */

14
15 public final class XSLComment extends XSLStringConstructor {
16
17     public void prepareAttributes() throws TransformerConfigurationException JavaDoc {
18         AttributeCollection atts = getAttributeList();
19         for (int a=0; a<atts.getLength(); a++) {
20             int nc = atts.getNameCode(a);
21             checkUnknownAttribute(nc);
22         }
23     }
24
25     public void validate() throws TransformerConfigurationException JavaDoc {
26         checkWithinTemplate();
27         optimize();
28     }
29
30     public void process(Context context) throws TransformerException JavaDoc
31     {
32         String JavaDoc comment = expandChildren(context);
33         
34         //TODO: do this checking at compile time if the content is fixed
35
while(true) {
36             int hh = comment.indexOf("--");
37             if (hh < 0) break;
38             context.getController().reportRecoverableError("Invalid characters (--) in comment", this);
39             comment = comment.substring(0, hh+1) + " " + comment.substring(hh+1);
40         }
41         if (comment.length()>0 && comment.charAt(comment.length()-1)=='-') {
42             context.getController().reportRecoverableError("Invalid character (-) at end of comment", this);
43             comment = comment + " ";
44         }
45         context.getOutputter().writeComment(comment);
46     }
47
48 }
49 //
50
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
51
// you may not use this file except in compliance with the License. You may obtain a copy of the
52
// License at http://www.mozilla.org/MPL/
53
//
54
// Software distributed under the License is distributed on an "AS IS" basis,
55
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
56
// See the License for the specific language governing rights and limitations under the License.
57
//
58
// The Original Code is: all this file.
59
//
60
// The Initial Developer of the Original Code is
61
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
62
//
63
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
64
//
65
// Contributor(s): none.
66
//
67
Popular Tags