Search in sources :

Example 46 with AutoPilot

use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.

the class ShapeParagraph method getChilderFragment.

private String getChilderFragment(String elementName) throws VTDException {
    String text = null;
    AutoPilot ap = getDeclareNSAutoPilot();
    ap.selectXPath("./" + elementName);
    vu.getVTDNav().push();
    if (ap.evalXPath() != -1) {
        text = vu.getElementFragment();
    }
    vu.getVTDNav().pop();
    return text;
}
Also used : AutoPilot(com.ximpleware.AutoPilot)

Example 47 with AutoPilot

use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.

the class ShapeParagraph method getCellValueText.

private String getCellValueText() {
    String result = "";
    try {
        AutoPilot ap = getDeclareNSAutoPilot();
        ap.selectXPath("/a:p/a:r");
        if (ap.evalXPath() != -1) {
            StringBuffer bf = new StringBuffer();
            do {
                String tVal = vu.getChildContent("a:t");
                bf.append(tVal);
            } while (ap.evalXPath() != -1);
            result = bf.toString();
        }
    } catch (VTDException e) {
        logger.error("", e);
    }
    return result;
}
Also used : VTDException(com.ximpleware.VTDException) AutoPilot(com.ximpleware.AutoPilot)

Example 48 with AutoPilot

use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.

the class ShapeTxBody method loadParagraph.

private void loadParagraph() {
    pList = new ArrayList<ShapeParagraph>();
    String xpath = "/xdr:txBody/a:p";
    AutoPilot ap = getDeclareNSAutoPilot();
    try {
        ap.selectXPath(xpath);
        while (ap.evalXPath() != -1) {
            ShapeParagraph p = new ShapeParagraph(vu.getElementFragment());
            pList.add(p);
        }
    } catch (VTDException e) {
        logger.error("", e);
    }
}
Also used : VTDException(com.ximpleware.VTDException) AutoPilot(com.ximpleware.AutoPilot)

Example 49 with AutoPilot

use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.

the class Cell method getNonTextContent.

/**
	 * Get rPh & phoneticPr Element fragment
	 * @return ;
	 */
private String getNonTextContent() {
    StringBuffer result = new StringBuffer();
    VTDGen vg = new VTDGen();
    vg.setDoc(content.getBytes());
    VTDUtils vu = null;
    try {
        vg.parse(true);
        vu = new VTDUtils(vg.getNav());
        AutoPilot ap = new AutoPilot(vu.getVTDNav());
        ap.selectXPath("/si/rPh | phoneticPr");
        while (ap.evalXPath() != -1) {
            result.append(vu.getElementFragment());
        }
    } catch (VTDException e) {
        e.printStackTrace();
    }
    return result.toString();
}
Also used : VTDUtils(net.heartsome.xml.vtdimpl.VTDUtils) VTDException(com.ximpleware.VTDException) AutoPilot(com.ximpleware.AutoPilot) VTDGen(com.ximpleware.VTDGen)

Example 50 with AutoPilot

use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.

the class Cell method loadCellCharacterStyle.

private List<Object[]> loadCellCharacterStyle(String content, String cellText) {
    List<Object[]> result = new ArrayList<Object[]>();
    VTDGen vg = new VTDGen();
    vg.setDoc(content.getBytes());
    VTDUtils vu = null;
    try {
        vg.parse(true);
        vu = new VTDUtils(vg.getNav());
        AutoPilot ap = new AutoPilot(vu.getVTDNav());
        ap.selectXPath("/si/r");
        if (ap.evalXPath() != -1) {
            StringBuffer bf = new StringBuffer();
            int start = 0;
            do {
                String rPrC = vu.getChildContent("rPr");
                if (rPrC != null) {
                    rPrC = "<rPr>" + rPrC + "</rPr>";
                    bf.append("rPr=\"").append(ReaderUtil.cleanAttribute(rPrC)).append("\"");
                } else {
                    bf.append(" ");
                }
                String tVal = vu.getChildContent("t");
                if (tVal == null || tVal.length() == 0) {
                    // clear
                    bf.delete(0, bf.length());
                    continue;
                }
                int sos = cellText.indexOf(tVal, start);
                int length = tVal.length();
                Object[] obj = new Object[3];
                obj[0] = sos;
                obj[1] = start = sos + length;
                obj[2] = bf.toString();
                result.add(obj);
                // clear
                bf.delete(0, bf.length());
            } while (ap.evalXPath() != -1);
        }
    } catch (VTDException e) {
        logger.error("", e);
    }
    return result;
}
Also used : VTDUtils(net.heartsome.xml.vtdimpl.VTDUtils) VTDException(com.ximpleware.VTDException) AutoPilot(com.ximpleware.AutoPilot) ArrayList(java.util.ArrayList) VTDGen(com.ximpleware.VTDGen)

Aggregations

AutoPilot (com.ximpleware.AutoPilot)308 VTDNav (com.ximpleware.VTDNav)173 NavException (com.ximpleware.NavException)150 XPathParseException (com.ximpleware.XPathParseException)145 XPathEvalException (com.ximpleware.XPathEvalException)137 VTDUtils (net.heartsome.xml.vtdimpl.VTDUtils)112 IOException (java.io.IOException)103 ModifyException (com.ximpleware.ModifyException)95 TranscodeException (com.ximpleware.TranscodeException)82 CoreException (org.eclipse.core.runtime.CoreException)76 UnsupportedEncodingException (java.io.UnsupportedEncodingException)58 VTDGen (com.ximpleware.VTDGen)50 FileNotFoundException (java.io.FileNotFoundException)49 XMLModifier (com.ximpleware.XMLModifier)46 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)44 ArrayList (java.util.ArrayList)42 HashMap (java.util.HashMap)39 XQException (javax.xml.xquery.XQException)37 LinkedHashMap (java.util.LinkedHashMap)34 LinkedList (java.util.LinkedList)25