private String getTypeName(VTDNav vn, Map<String, String> namespaceMap, int i) throws NavException { String elementName = vn.toRawString(i); int indexOfColon = elementName.indexOf(':'); String namespace = elementName.substring(0, indexOfColon); String name = elementName.substring(indexOfColon + 1); String nsUri = XmiSplitUtilities.convertNSUri(namespaceMap.get(namespace)); return nsUri + name; } }
public void readBinaryAttachment(HTTPInputStream input) throws VTDException, IOException{ // first read xml bytes into XMLBytes .... VTDGen vg = new VTDGen(); vg.setDoc(XMLBytes); vg.parse(false);// VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/ProcessRequest/BinaryAttachment/text()"); int i=0; while((i=ap.evalXPath())!=-1){ //i points to text node of String s = vn.toRawString(i); // you need to decode them } }
@Override protected String getNodeXml(JeDISVTDGraphNode node) throws XMISplitterException { try { return vn.toRawString(node.getByteOffset(), node.getByteLength()); } catch (NavException e) { throw new XMISplitterException(e); } }
private String getString(VTDNav vn){ if (argCount== 0) try{ if (vn.atTerminal){ if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_CDATA_VAL ) return vn.toRawString(vn.LN); return vn.toString(vn.LN); } return vn.getXPathStringVal(); } catch(NavException e){ return ""; // this will almost never occur } else if (argCount == 1){ return argumentList.e.evalString(vn); } else throw new IllegalArgumentException ("String()'s argument count is invalid"); }
private String getString(VTDNav vn){ if (argCount== 0) try{ if (vn.atTerminal){ if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_CDATA_VAL ) return vn.toRawString(vn.LN); return vn.toString(vn.LN); } return vn.getXPathStringVal(); } catch(NavException e){ return ""; // this will almost never occur } else if (argCount == 1){ return argumentList.e.evalString(vn); } else throw new IllegalArgumentException ("String()'s argument count is invalid"); }
/** * Return the prefix of a token as a string if the token * is of the type of starting tag, attribute name, if the * the prefix doesn't exist, a null string is returned; * otherwise a null string is returned * * @param i VTD index of a token * @return */ public String getPrefixString(int i) throws NavException{ if (ns == false) return null; int type = getTokenType(i); if (type != TOKEN_ATTR_NAME && type != TOKEN_STARTING_TAG) return null; int offset = getTokenOffset(i); int preLen = getTokenLength(i) >> 16; if (preLen !=0) return toRawString(offset,preLen); return null; }
private String getString(VTDNav vn){ if (argCount== 0) try{ if (vn.atTerminal){ if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_CDATA_VAL ) return vn.toRawString(vn.LN); return vn.toString(vn.LN); } return vn.getXPathStringVal(); } catch(NavException e){ return ""; // this will almost never occur } else if (argCount == 1){ return argumentList.e.evalString(vn); } else throw new IllegalArgumentException ("String()'s argument count is invalid"); }
/** * Return the prefix of a token as a string if the token * is of the type of starting tag, attribute name, if the * the prefix doesn't exist, a null string is returned; * otherwise a null string is returned * * @param i VTD index of a token * @return */ public String getPrefixString(int i) throws NavException{ if (ns == false) return null; int type = getTokenType(i); if (type != TOKEN_ATTR_NAME && type != TOKEN_STARTING_TAG) return null; int offset = getTokenOffset(i); int preLen = getTokenLength(i) >> 16; if (preLen !=0) return toRawString(offset,preLen); return null; }
/** * Return the prefix of a token as a string if the token * is of the type of starting tag, attribute name, if the * the prefix doesn't exist, a null string is returned; * otherwise a null string is returned * * @param i VTD index of a token * @return */ public String getPrefixString(int i) throws NavException{ if (ns == false) return null; int type = getTokenType(i); if (type != TOKEN_ATTR_NAME && type != TOKEN_STARTING_TAG) return null; int offset = getTokenOffset(i); int preLen = getTokenLength(i) >> 16; if (preLen !=0) return toRawString(offset,preLen); return null; }
final protected void toRawString(StringBuilder sb, int index) throws NavException { int type = getTokenType(index); int len; if (type == TOKEN_STARTING_TAG || type == TOKEN_ATTR_NAME || type == TOKEN_ATTR_NS) len = getTokenLength2(index) & 0xffff; else len = getTokenLength2(index); int offset = getTokenOffset(index); toRawString(offset, len,sb); } /**
final protected void toRawString(StringBuilder sb, int index) throws NavException { int type = getTokenType(index); int len; if (type == TOKEN_STARTING_TAG || type == TOKEN_ATTR_NAME || type == TOKEN_ATTR_NS) len = getTokenLength2(index) & 0xffff; else len = getTokenLength2(index); int offset = getTokenOffset(index); toRawString(offset, len,sb); } /**
final protected void toString(StringBuilder sb, int index) throws NavException { /*int type = getTokenType(index); if (type!=TOKEN_CHARACTER_DATA && type!= TOKEN_ATTR_VAL) toRawString(sb, index);*/ int len,type; len = getTokenLength2(index); type= getTokenType(index); int offset = getTokenOffset(index); if (type!=VTDNav.TOKEN_CDATA_VAL) toString(offset, len, sb); else toRawString(offset, len, sb); }
final protected void toString(StringBuilder sb, int index) throws NavException { /*int type = getTokenType(index); if (type!=TOKEN_CHARACTER_DATA && type!= TOKEN_ATTR_VAL) toRawString(sb, index);*/ int len,type; len = getTokenLength2(index); type= getTokenType(index); int offset = getTokenOffset(index); if (type!=VTDNav.TOKEN_CDATA_VAL) toString(offset, len, sb); else toRawString(offset, len, sb); }
final protected void toString(StringBuilder sb, int index) throws NavException { /*int type = getTokenType(index); if (type!=TOKEN_CHARACTER_DATA && type!= TOKEN_ATTR_VAL) toRawString(sb, index);*/ int len,type; len = getTokenLength2(index); type= getTokenType(index); int offset = getTokenOffset(index); if (type!=VTDNav.TOKEN_CDATA_VAL) toString(offset, len, sb); else toRawString(offset, len, sb); }
/** * Convert a token at the given index to a String, (entities and char * references resolved character data and attr val). An attribute name or * an element name will get the UCS2 string of qualified name * Creation date: (11/16/03 7:27:19 PM) * * @return java.lang.String * @param index * @exception NavException */ public String toString(int index) throws NavException { int type = getTokenType(index); if (type!=TOKEN_CHARACTER_DATA && type!= TOKEN_ATTR_VAL) return toRawString(index); int len; len = getTokenLength(index); int offset = getTokenOffset(index); return toString(offset, len); }
/** * Convert a token at the given index to a String, (entities and char * references resolved character data and attr val). An attribute name or * an element name will get the UCS2 string of qualified name * Creation date: (11/16/03 7:27:19 PM) * * @return java.lang.String * @param index * @exception NavException */ public String toString(int index) throws NavException { int type = getTokenType(index); if (type!=TOKEN_CHARACTER_DATA && type!= TOKEN_ATTR_VAL) return toRawString(index); int len; len = getTokenLength(index); int offset = getTokenOffset(index); return toString(offset, len); }
import com.ximpleware.*; public class dumpKeyValue { public static void main(String[] s) throws VTDException{ VTDGen vg = new VTDGen(); AutoPilot ap = new AutoPilot(); ap.selectXPath("//part/*[text()]"); if (!vg.parseFile("d:\\xml\\soap.xml", false)){ System.out.println("invalid xml"); System.exit(0); } VTDNav vn = vg.getNav(); ap.bind(vn); int i=0; while((i=ap.evalXPath())!=-1){ System.out.println(" "+vn.toRawString(i)+" = "+vn.toNormalizedString(vn.getText())); } } }
/** * Convert a token at the given index to a String, * (entities and char references not expanded). * Creation date: (11/16/03 7:28:49 PM) * * @return java.lang.String * @param index int * @exception NavException When the encoding has errors */ final public String toRawString(int index) throws NavException { int type = getTokenType(index); int len; if (type == TOKEN_STARTING_TAG || type == TOKEN_ATTR_NAME || type == TOKEN_ATTR_NS) len = getTokenLength(index) & 0xffff; else len = getTokenLength(index); int offset = getTokenOffset(index); return toRawString(offset, len); }
/** * Convert a token at the given index to a String, * (entities and char references not expanded). * Creation date: (11/16/03 7:28:49 PM) * * @return java.lang.String * @param index int * @exception NavException When the encoding has errors */ final public String toRawString(int index) throws NavException { int type = getTokenType(index); int len; if (type == TOKEN_STARTING_TAG || type == TOKEN_ATTR_NAME || type == TOKEN_ATTR_NS) len = getTokenLength(index) & 0xffff; else len = getTokenLength(index); int offset = getTokenOffset(index); return toRawString(offset, len); }
import com.ximpleware.*; public class dumpKeyValue { public static void main(String[] s) throws VTDException{ VTDGen vg = new VTDGen(); AutoPilot ap = new AutoPilot(); ap.selectXPath("//*[text()]"); if (!vg.parseFile("d:\\xml\\keyValue.xml", false)){ System.out.println("invalid xml"); System.exit(0); } VTDNav vn = vg.getNav(); ap.bind(vn); int i=0; while((i=ap.evalXPath())!=-1){ System.out.println(" "+vn.toRawString(i)+" = "+vn.toNormalizedString(vn.getText())); } } }