コード例 #1
0
ファイル: AutoPilot.cs プロジェクト: zanyants/vtd-xml
        /// <summary> This method implements the attribute axis for XPath</summary>
        /// <returns> the integer of the selected VTD index for attribute name
        /// </returns>
        /// <throws>  PilotException </throws>
        public int iterateAttr()
        {
            switch (iter_type)
            {
            case ATTR:
                if (String.CompareOrdinal(name, "*") == 0)
                {
                    if (ft != false)
                    {
                        ft    = false;
                        index = vn.getCurrentIndex2() + 1;
                    }
                    else
                    {
                        index += 2;
                    }
                    if (vn.ns == false)
                    {
                        while (index < size)
                        {
                            int type = vn.getTokenType(index);
                            if (type == VTDNav.TOKEN_ATTR_NAME || type == VTDNav.TOKEN_ATTR_NS)
                            {
                                //vn.LN = index;
                                return(index);
                            }
                            else
                            {
                                return(-1);
                            }
                        }
                        return(-1);
                    }
                    else
                    {
                        while (index < size)
                        {
                            int type = vn.getTokenType(index);
                            if (type == VTDNav.TOKEN_ATTR_NAME || type == VTDNav.TOKEN_ATTR_NS)
                            {
                                if (type == VTDNav.TOKEN_ATTR_NAME)
                                {
                                    //vn.LN = index;
                                    return(index);
                                }
                                else
                                {
                                    index += 2;
                                }
                            }
                            else
                            {
                                return(-1);
                            }
                        }
                        return(-1);
                    }
                }
                else
                {
                    if (ft == false)
                    {
                        return(-1);
                    }
                    else
                    {
                        ft = false;
                        int i = vn.getAttrVal(name);
                        if (i != -1)
                        {
                            //vn.LN = i - 1;
                            return(i - 1);
                        }
                        else
                        {
                            return(-1);
                        }
                    }
                }
            //goto case ATTR_NS;

            case ATTR_NS:
                if (ft == false)
                {
                    return(-1);
                }
                else
                {
                    ft = false;
                    int i = vn.getAttrValNS(URL, localName);
                    if (i != -1)
                    {
                        //vn.LN = i - 1;
                        return(i - 1);
                    }
                    else
                    {
                        return(-1);
                    }
                }
            //goto default;

            default:
                throw new PilotException("invalid iteration type");
            }
        }