toNormalizedString() public method

This method normalizes a token into a string in a way that resembles DOM. The leading and trailing white space characters will be stripped. The entity and character references will be resolved Multiple whitespaces char will be collapsed into one. Whitespaces via entities will nonetheless be preserved. Creation date: (12/8/03 1:57:10 PM)
When the encoding has errors ///
public toNormalizedString ( int index ) : System.String
index int int ///
return System.String
Beispiel #1
0
        private System.String normalizeSpace(VTDNav vn)
        {
            if (argCount1 == 0)
            {
                String s = null;
                try
                {
                    if (vn.atTerminal)
                    {
                        int ttype = vn.getTokenType(vn.LN);
                        if (ttype == VTDNav.TOKEN_CDATA_VAL)
                            s = vn.toRawString(vn.LN);
                        else if (ttype == VTDNav.TOKEN_ATTR_NAME ||
                             ttype == VTDNav.TOKEN_ATTR_NS)
                        {
                            s = vn.toString(vn.LN + 1);
                        }
                        else
                            s = vn.toString(vn.LN);
                    }
                    else
                    {
                        int i = vn.getCurrentIndex();
                        int t = vn.getTokenType(i);
                        if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT)
                        {
                            s = vn.toNormalizedXPathString(i);
                        }
                        else
                            s = vn.toNormalizedString(i);
                    }
                    return normalize(s);
                }
                catch (NavException e)
                {
                    return ""; // this will almost never occur
                }
            }
            else if (argCount1 == 1)
            {
                String s = "";
                if (argumentList.e.NodeSet)
                {
                    //boolean b = false;
                    int a = evalFirstArgumentListNodeSet(vn);
                    if (a == -1)
                        return "";
                    else
                    {
                        try
                        {
                            int t = vn.getTokenType(a);
                            if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT)
                            {
                                s = vn.toNormalizedXPathString(a);
                            }
                            else
                                s = vn.toNormalizedString(a);
                        }
                        catch (Exception e)
                        {
                        }
                        return s;
                    }
                }
                else
                {
                    s = argumentList.e.evalString(vn);
                    return normalize(s);
                }
	        
            }
            throw new System.ArgumentException("normalize-space()'s argument count is invalid");
            //return null;
        }