KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.icl.saxon.style;
2 import com.icl.saxon.tree.AttributeCollection;
3 import com.icl.saxon.*;
4 import com.icl.saxon.expr.*;
5 import javax.xml.transform.*;
6
7 import org.w3c.dom.Node JavaDoc;
8
9 /**
10 * A saxon:item element in the stylesheet. Iterates within a group provided the
11 * key value is the same as the previous item<BR>
12 */

13
14 public class SAXONItem extends StyleElement {
15
16     private SAXONGroup group;
17
18     public void prepareAttributes() throws TransformerConfigurationException {
19         AttributeCollection atts = getAttributeList();
20         for (int a=0; a<atts.getLength(); a++) {
21             int nc = atts.getNameCode(a);
22             checkUnknownAttribute(nc);
23         }
24     }
25
26     /**
27     * Determine whether this type of element is allowed to contain a template-body
28     * @return true: yes, it may contain a template-body
29     */

30
31     public boolean mayContainTemplateBody() {
32         return true;
33     }
34
35     public void validate() throws TransformerConfigurationException {
36         checkWithinTemplate();
37         Node JavaDoc parent = getParentNode();
38         while (parent!=null) {
39             if (parent instanceof SAXONGroup) {
40                 group = (SAXONGroup)parent;
41                 break;
42             }
43             parent = parent.getParentNode();
44         }
45
46         if (group==null) {
47             compileError("saxon:item must be within a saxon:group");
48         }
49
50     }
51
52     public void process(Context context) throws TransformerException
53     {
54         GroupActivation f = (GroupActivation)context.getGroupActivationStack().peek();
55         
56         while(true) {
57             processChildren(context);
58             if (!f.sameAsNext()) break;
59             f.nextElement();
60         }
61     }
62
63 }
64
65 //
66
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
67
// you may not use this file except in compliance with the License. You may obtain a copy of the
68
// License at http://www.mozilla.org/MPL/
69
//
70
// Software distributed under the License is distributed on an "AS IS" basis,
71
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
72
// See the License for the specific language governing rights and limitations under the License.
73
//
74
// The Original Code is: all this file.
75
//
76
// The Initial Developer of the Original Code is
77
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
78
//
79
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
80
//
81
// Contributor(s): none.
82
//
83
Popular Tags