001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 /*
019 * $Id: AttributeIterator.java 468655 2006-10-28 07:12:06Z minchau $
020 */
021 package org.apache.xpath.axes;
022
023 import org.apache.xml.dtm.DTM;
024 import org.apache.xpath.compiler.Compiler;
025
026 /**
027 * This class implements an optimized iterator for
028 * attribute axes patterns.
029 * @see org.apache.xpath.axes#ChildTestIterator
030 * @xsl.usage advanced
031 */
032 public class AttributeIterator extends ChildTestIterator
033 {
034 static final long serialVersionUID = -8417986700712229686L;
035
036 /**
037 * Create a AttributeIterator object.
038 *
039 * @param compiler A reference to the Compiler that contains the op map.
040 * @param opPos The position within the op map, which contains the
041 * location path expression for this itterator.
042 *
043 * @throws javax.xml.transform.TransformerException
044 */
045 AttributeIterator(Compiler compiler, int opPos, int analysis)
046 throws javax.xml.transform.TransformerException
047 {
048 super(compiler, opPos, analysis);
049 }
050
051 /**
052 * Get the next node via getFirstAttribute && getNextAttribute.
053 */
054 protected int getNextNode()
055 {
056 m_lastFetched = (DTM.NULL == m_lastFetched)
057 ? m_cdtm.getFirstAttribute(m_context)
058 : m_cdtm.getNextAttribute(m_lastFetched);
059 return m_lastFetched;
060 }
061
062 /**
063 * Returns the axis being iterated, if it is known.
064 *
065 * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple
066 * types.
067 */
068 public int getAxis()
069 {
070 return org.apache.xml.dtm.Axis.ATTRIBUTE;
071 }
072
073
074
075 }