1 /* 2 * Copyright 1999-2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 /* 17 * $Id: TransformState.java,v 1.9 2004/02/16 20:41:29 minchau Exp $ 18 */ 19 package org.apache.xalan.transformer; 20 21 import javax.xml.transform.Transformer; 22 23 import org.apache.xalan.templates.ElemTemplate; 24 import org.apache.xalan.templates.ElemTemplateElement; 25 import org.apache.xml.serializer.TransformStateSetter; 26 27 import org.w3c.dom.Node; 28 import org.w3c.dom.traversal.NodeIterator; 29 30 /** 31 * This interface is meant to be used by a consumer of 32 * SAX2 events produced by Xalan, and enables the consumer 33 * to get information about the state of the transform. It 34 * is primarily intended as a tooling interface. A content 35 * handler can get a reference to a TransformState by implementing 36 * the TransformerClient interface. Xalan will check for 37 * that interface before it calls startDocument, and, if it 38 * is implemented, pass in a TransformState reference to the 39 * setTransformState method. 40 * 41 * <p>Note that the current stylesheet and root stylesheet can 42 * be retrieved from the ElemTemplateElement obtained from 43 * either getCurrentElement() or getCurrentTemplate().</p> 44 * 45 * This interface contains only getter methods, any setters are in the interface 46 * TransformStateSetter which this interface extends. 47 * 48 * @see org.apache.xml.serializer.TransformStateSetter 49 */ 50 public interface TransformState extends TransformStateSetter 51 { 52 53 /** 54 * Retrieves the stylesheet element that produced 55 * the SAX event. 56 * 57 * <p>Please note that the ElemTemplateElement returned may 58 * be in a default template, and thus may not be 59 * defined in the stylesheet.</p> 60 * 61 * @return the stylesheet element that produced the SAX event. 62 */ 63 ElemTemplateElement getCurrentElement(); 64 65 /** 66 * This method retrieves the current context node 67 * in the source tree. 68 * 69 * @return the current context node in the source tree. 70 */ 71 Node getCurrentNode(); 72 73 /** 74 * This method retrieves the xsl:template 75 * that is in effect, which may be a matched template 76 * or a named template. 77 * 78 * <p>Please note that the ElemTemplate returned may 79 * be a default template, and thus may not have a template 80 * defined in the stylesheet.</p> 81 * 82 * @return the xsl:template that is in effect 83 */ 84 ElemTemplate getCurrentTemplate(); 85 86 /** 87 * This method retrieves the xsl:template 88 * that was matched. Note that this may not be 89 * the same thing as the current template (which 90 * may be from getCurrentElement()), since a named 91 * template may be in effect. 92 * 93 * <p>Please note that the ElemTemplate returned may 94 * be a default template, and thus may not have a template 95 * defined in the stylesheet.</p> 96 * 97 * @return the xsl:template that was matched. 98 */ 99 ElemTemplate getMatchedTemplate(); 100 101 /** 102 * Retrieves the node in the source tree that matched 103 * the template obtained via getMatchedTemplate(). 104 * 105 * @return the node in the source tree that matched 106 * the template obtained via getMatchedTemplate(). 107 */ 108 Node getMatchedNode(); 109 110 /** 111 * Get the current context node list. 112 * 113 * @return the current context node list. 114 */ 115 NodeIterator getContextNodeList(); 116 117 /** 118 * Get the TrAX Transformer object in effect. 119 * 120 * @return the TrAX Transformer object in effect. 121 */ 122 Transformer getTransformer(); 123 124 125 126 } 127