/** * This method will insert a segment of the byte array (contained in vn, and * transcode into a byte array) before the tail of cursor element, * @param vn * @param contentOffset * @param contentLen * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(VTDNav vn, int contentOffset, int contentLen) throws ModifyException, NavException,TranscodeException { insertBeforeTail(vn.XMLDoc.getBytes(),contentOffset, contentLen); } /**
/** * This method will insert a segment of the byte array (contained in vn, and * transcode into a byte array) before the tail of cursor element, * l1 (a long)'s upper 32 bit is length, lower 32 bit is offset * * @param vn * @param l1 * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(VTDNav vn, long l1) throws ModifyException, NavException, TranscodeException { insertBeforeTail(vn.encoding, vn.XMLDoc.getBytes(), l1); }
/** * This method will insert a segment of the byte array (contained in vn, and * transcode into a byte array) before the tail of cursor element, * l1 (a long)'s upper 32 bit is length, lower 32 bit is offset * * @param vn * @param l1 * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(VTDNav vn, long l1) throws ModifyException, NavException, TranscodeException { insertBeforeTail(vn.encoding, vn.XMLDoc.getBytes(), l1); }
/** * This method will insert a segment of the byte array (contained in vn, and * transcode into a byte array) before the tail of cursor element, * @param vn * @param contentOffset * @param contentLen * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(VTDNav vn, int contentOffset, int contentLen) throws ModifyException, NavException,TranscodeException { insertBeforeTail(vn.XMLDoc.getBytes(),contentOffset, contentLen); } /**
/** * This method will insert a segment of the byte array (contained in vn, and * transcode into a byte array) before the tail of cursor element, * l1 (a long)'s upper 32 bit is length, lower 32 bit is offset * * @param vn * @param l1 * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(VTDNav vn, long l1) throws ModifyException, NavException, TranscodeException { insertBeforeTail(vn.encoding, vn.XMLDoc.getBytes(), l1); }
/** * This method will insert a segment of the byte array (contained in vn, and * transcode into a byte array) before the tail of cursor element, * @param vn * @param contentOffset * @param contentLen * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(VTDNav vn, int contentOffset, int contentLen) throws ModifyException, NavException,TranscodeException { insertBeforeTail(vn.XMLDoc.getBytes(),contentOffset, contentLen); } /**
import com.ximpleware.*; import java.io.*; public class merge { // merge second.xml into first.xml assuming the same encoding public static void main(String[] s) throws VTDException, IOException{ VTDGen vg = new VTDGen(); if (!vg.parseFile("d:\\xml\\first.xml", false)) return; VTDNav vn1=vg.getNav(); if(!vg.parseFile("d:\\xml\\second.xml", false)) return; VTDNav vn2 = vg.getNav(); XMLModifier xm = new XMLModifier(vn1); long l = vn2.getContentFragment(); xm.insertBeforeTail(vn2, l); xm.output("d:\\xml\\merged.xml"); } }
/** * This method will insert the transcoded representation of byte array b right before the tail of cursor element, * @param src_encoding * @param b * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(int src_encoding, byte[] b) throws ModifyException, NavException,TranscodeException { if(src_encoding == encoding){ insertBeforeTail(b); }else{ long i = md.getOffsetBeforeTail(); if (i<0){ //throw new ModifyException("Insertion failed"); insertAfterHead(src_encoding,b); return; } byte[] bo = Transcoder.transcode(b, 0, b.length, src_encoding, encoding); insertBytesAt((int)i,bo); } } /**
/** * This method will insert the transcoded representation of byte array b right before the tail of cursor element, * @param src_encoding * @param b * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(int src_encoding, byte[] b) throws ModifyException, NavException,TranscodeException { if(src_encoding == encoding){ insertBeforeTail(b); }else{ long i = md.getOffsetBeforeTail(); if (i<0){ //throw new ModifyException("Insertion failed"); insertAfterHead(src_encoding,b); return; } byte[] bo = Transcoder.transcode(b, 0, b.length, src_encoding, encoding); insertBytesAt((int)i,bo); } } /**
/** * This method will insert the transcoded representation of byte array b right before the tail of cursor element, * @param src_encoding * @param b * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(int src_encoding, byte[] b) throws ModifyException, NavException,TranscodeException { if(src_encoding == encoding){ insertBeforeTail(b); }else{ long i = md.getOffsetBeforeTail(); if (i<0){ //throw new ModifyException("Insertion failed"); insertAfterHead(src_encoding,b); return; } byte[] bo = Transcoder.transcode(b, 0, b.length, src_encoding, encoding); insertBytesAt((int)i,bo); } } /**
/** * This method will insert the transcoded representation of a segment of the byte array before the tail of cursor element, * l1 (a long)'s upper 32 bit is length, lower 32 bit is offset * @param src_encoding * @param b * @param l * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(int src_encoding, byte[] b, long l) throws ModifyException, NavException,TranscodeException { if(src_encoding == encoding){ insertBeforeTail(b,l); }else{ long i = md.getOffsetBeforeTail(); if (i<0){ //throw new ModifyException("Insertion failed"); insertAfterHead(src_encoding,b,l); return; } byte[] bo = Transcoder.transcode(b, (int)l, (int)l>>32, src_encoding, encoding); insertBytesAt((int)i,bo,l); } } /**
/** * This method will insert the transcoded representation of a segment of the byte array before the tail of cursor element, * l1 (a long)'s upper 32 bit is length, lower 32 bit is offset * @param src_encoding * @param b * @param l * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(int src_encoding, byte[] b, long l) throws ModifyException, NavException,TranscodeException { if(src_encoding == encoding){ insertBeforeTail(b,l); }else{ long i = md.getOffsetBeforeTail(); if (i<0){ //throw new ModifyException("Insertion failed"); insertAfterHead(src_encoding,b,l); return; } byte[] bo = Transcoder.transcode(b, (int)l, (int)l>>32, src_encoding, encoding); insertBytesAt((int)i,bo,l); } } /**
/** * This method will insert the transcoded representation of a segment of the byte array before the tail of cursor element, * l1 (a long)'s upper 32 bit is length, lower 32 bit is offset * @param src_encoding * @param b * @param l * @throws ModifyException * @throws NavException * @throws TranscodeException */ public void insertBeforeTail(int src_encoding, byte[] b, long l) throws ModifyException, NavException,TranscodeException { if(src_encoding == encoding){ insertBeforeTail(b,l); }else{ long i = md.getOffsetBeforeTail(); if (i<0){ //throw new ModifyException("Insertion failed"); insertAfterHead(src_encoding,b,l); return; } byte[] bo = Transcoder.transcode(b, (int)l, (int)l>>32, src_encoding, encoding); insertBytesAt((int)i,bo,l); } } /**
xm.removeContent((int)(l2),(int)(l2>>32)); l3= fib.longAt(j); xm.insertBeforeTail(vn,l3); xm.output("d:\\xml\\outMessage"+(j+1)+".xml"); xm.reset();