Exemplo n.º 1
0
 /**
  * Runs a query and checks the serialization parameters.
  *
  * @throws IOException I/O exception
  */
 @Test
 public void queryOptions() throws IOException {
   final Query query = session.query("declare option output:encoding 'US-ASCII';()");
   query.execute();
   final SerializerOptions sp = new SerializerOptions();
   sp.parse(query.options());
   assertEquals("US-ASCII", sp.get(SerializerOptions.ENCODING));
   query.close();
 }
Exemplo n.º 2
0
  /** Tests the namespace stripping option (Option {@link MainOptions#STRIPNS}). */
  @Test
  public void parse() {
    set(MainOptions.STRIPNS, true);
    set(MainOptions.SERIALIZER, SerializerOptions.get(false));

    final String doc = "<e xmlns='A'><b:f xmlns:b='B'/></e>";
    for (final boolean b : new boolean[] {false, true}) {
      set(MainOptions.INTPARSE, b);
      execute(new CreateDB(NAME, doc));
      assertEquals("<e><f/></e>", query("."));
      assertEquals("<f/>", query("e/f"));
    }
  }
Exemplo n.º 3
0
  /** Tests the xml:space attribute. */
  @Test
  public void xmlSpace() {
    set(MainOptions.SERIALIZER, SerializerOptions.get(false));

    final String in =
        "<x><a xml:space='default'> </a><a> </a>" + "<a xml:space='preserve'> </a></x>";
    final String out = "<x><a xml:space=\"default\"/><a/>" + "<a xml:space=\"preserve\"> </a></x>";

    for (final boolean b : new boolean[] {true, false}) {
      set(MainOptions.INTPARSE, b);
      execute(new CreateDB(NAME, in));
      assertEquals("Internal parser: " + b, out, query("."));
    }
  }
Exemplo n.º 4
0
 /** Creates the database context. */
 @BeforeClass
 public static void start() {
   // turn off pretty printing
   set(MainOptions.SERIALIZER, SerializerOptions.get(false));
 }