Search in sources :

Example 6 with AutoPilot

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

the class VTDUtilsTest method testGetCurrentElementAttributs2Params.

@Test
public void testGetCurrentElementAttributs2Params() throws XPathParseException, XPathEvalException, NavException {
    AutoPilot ap = new AutoPilot(vn);
    ap.selectXPath("//trans-unit[position()=2]");
    ap.evalXPath();
    Hashtable<String, String> eAtts = new Hashtable<String, String>();
    eAtts.put("approved", "yes");
    eAtts.put("id", "1");
    eAtts.put("merged-trans", "yes");
    eAtts.put("reformat", "yes");
    eAtts.put("size-unit", "pixel");
    eAtts.put("translate", "yes");
    eAtts.put("xml:space", "preserve");
    eAtts.put("hs:ext", "yes");
    eAtts.put("xsi:test", "test");
    Hashtable<String, String> ns = new Hashtable<String, String>();
    ns.put("http://www.heartsome.net.cn/2008/XLFExtension", "es");
    ns.put("http://www.w3.org/2001/XMLSchema-instance", "es");
    Hashtable<String, String> aAtts = vu.getCurrentElementAttributs(ns);
    assertEquals(eAtts, aAtts);
}
Also used : AutoPilot(com.ximpleware.AutoPilot) Hashtable(java.util.Hashtable) Test(org.junit.Test)

Example 7 with AutoPilot

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

the class VTDUtilsTest method testGetChildElementsCount.

@Test
public void testGetChildElementsCount() throws XPathParseException, XPathEvalException, NavException {
    AutoPilot ap = new AutoPilot(vn);
    ap.selectXPath("/xliff");
    ap.evalXPath();
    int count = vu.getChildElementsCount();
    assertEquals(2, count);
}
Also used : AutoPilot(com.ximpleware.AutoPilot) Test(org.junit.Test)

Example 8 with AutoPilot

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

the class VTDUtilsTest method testGetChildrenContent.

@Test
public void testGetChildrenContent() throws XPathParseException, XPathEvalException, NavException {
    AutoPilot ap = new AutoPilot(vn);
    ap.selectXPath("//trans-unit[position()=2]");
    ap.evalXPath();
    Vector<String> notes = vu.getChildrenContent("note");
    assertEquals(3, notes.size());
    assertEquals("The 1 note.", notes.get(0));
    assertEquals("The 2 note.", notes.get(1));
    assertEquals("The 3 note.", notes.get(2));
}
Also used : AutoPilot(com.ximpleware.AutoPilot) Test(org.junit.Test)

Example 9 with AutoPilot

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

the class VTDUtilsTest method testGetElementContent.

@Test
public void testGetElementContent() throws NavException, XPathParseException, XPathEvalException {
    AutoPilot ap = new AutoPilot(vn);
    ap.selectXPath("//trans-unit/note[position()=1]");
    int inx = ap.evalXPath();
    assertNotSame(-1, inx);
    String txt = vu.getElementContent();
    assertEquals("The note 1.", txt);
}
Also used : AutoPilot(com.ximpleware.AutoPilot) Test(org.junit.Test)

Example 10 with AutoPilot

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

the class VTDUtilsTest method testGetElementPureText.

@Test
public void testGetElementPureText() throws XPathParseException, XPathEvalException, NavException {
    AutoPilot ap = new AutoPilot(vn);
    ap.selectXPath("//trans-unit[position()=1]/source");
    int inx = ap.evalXPath();
    assertNotSame(-1, inx);
    String txt = vu.getElementPureText();
    assertEquals("This is the first test.", txt);
}
Also used : AutoPilot(com.ximpleware.AutoPilot) Test(org.junit.Test)

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