Search in sources :

Example 6 with PropBean

use of net.heartsome.cat.ts.core.bean.PropBean in project translationstudio8 by heartsome.

the class TSFileHandler method getProps.

// 获取当前节点下的属性元素子节点。
private Vector<PropBean> getProps(VTDUtils vu) throws XPathParseException, XPathEvalException, NavException {
    VTDNav vn = vu.getVTDNav();
    Vector<PropBean> props = new Vector<PropBean>();
    AutoPilot ap = new AutoPilot(vn);
    ap.selectXPath("./prop");
    while (ap.evalXPath() != -1) {
        String proptype = null;
        String value = null;
        String lang = null;
        int attInx = vn.getAttrVal("prop-type");
        if (attInx != -1) {
            proptype = vn.toString(attInx);
        }
        attInx = vn.getAttrVal("xml:lang");
        if (attInx != -1) {
            lang = vn.toString(attInx);
        }
        value = vu.getElementContent();
        PropBean prop = new PropBean(proptype, value, lang);
        props.add(prop);
    }
    ap.resetXPath();
    ap.declareXPathNameSpace(hsNSPrefix, hsR7NSUrl);
    ap.selectXPath("./hs:prop");
    while (ap.evalXPath() != -1) {
        String proptype = null;
        String value = null;
        String lang = null;
        int attInx = vn.getAttrVal("prop-type");
        if (attInx != -1) {
            proptype = vn.toString(attInx);
        }
        attInx = vn.getAttrVal("xml:lang");
        if (attInx != -1) {
            lang = vn.toString(attInx);
        }
        value = vu.getElementContent();
        PropBean prop = new PropBean(proptype, value, lang);
        props.add(prop);
    }
    if (props.isEmpty()) {
        props = null;
    }
    return props;
}
Also used : AutoPilot(com.ximpleware.AutoPilot) PropBean(net.heartsome.cat.ts.core.bean.PropBean) VTDNav(com.ximpleware.VTDNav) Vector(java.util.Vector)

Example 7 with PropBean

use of net.heartsome.cat.ts.core.bean.PropBean in project translationstudio8 by heartsome.

the class TSFileHandler method getPrpoGroups.

// 获取当前节点下的属性组集合。
private Vector<PropGroupBean> getPrpoGroups(VTDUtils vu) throws XPathParseException, XPathEvalException, NavException {
    VTDNav vn = vu.getVTDNav();
    Vector<PropGroupBean> pgs = new Vector<PropGroupBean>();
    AutoPilot ap = new AutoPilot(vn);
    ap.selectXPath("./prop-group");
    while (ap.evalXPath() != -1) {
        vn.push();
        Vector<PropBean> props = getProps(vu);
        vn.pop();
        PropGroupBean pg = new PropGroupBean(props);
        // 获取属性组名称。
        int nameInx = vn.getAttrVal("name");
        if (nameInx != -1) {
            pg.setName(vn.toString(nameInx));
        }
        pgs.add(pg);
    }
    ap.resetXPath();
    ap.declareXPathNameSpace(hsNSPrefix, hsR7NSUrl);
    ap.selectXPath("./hs:prop-group");
    while (ap.evalXPath() != -1) {
        vn.push();
        Vector<PropBean> props = getProps(vu);
        vn.pop();
        PropGroupBean pg = new PropGroupBean(props);
        // 获取属性组名称。
        int nameInx = vn.getAttrVal("name");
        if (nameInx != -1) {
            pg.setName(vn.toString(nameInx));
        }
        pgs.add(pg);
    }
    if (pgs.isEmpty()) {
        pgs = null;
    }
    return pgs;
}
Also used : PropGroupBean(net.heartsome.cat.ts.core.bean.PropGroupBean) AutoPilot(com.ximpleware.AutoPilot) PropBean(net.heartsome.cat.ts.core.bean.PropBean) VTDNav(com.ximpleware.VTDNav) Vector(java.util.Vector)

Aggregations

PropBean (net.heartsome.cat.ts.core.bean.PropBean)7 Vector (java.util.Vector)6 PropGroupBean (net.heartsome.cat.ts.core.bean.PropGroupBean)5 AutoPilot (com.ximpleware.AutoPilot)4 VTDNav (com.ximpleware.VTDNav)4 AltTransBean (net.heartsome.cat.ts.core.bean.AltTransBean)3 Hashtable (java.util.Hashtable)2 FuzzySearchResult (net.heartsome.cat.common.bean.FuzzySearchResult)2 TmxProp (net.heartsome.cat.common.bean.TmxProp)2 TmxTU (net.heartsome.cat.common.bean.TmxTU)2 GridItem (org.eclipse.nebula.widgets.grid.GridItem)1 IEditorReference (org.eclipse.ui.IEditorReference)1