コード例 #1
0
 private String findDefaultSelectedCaseId() {
   // TODO: Use ElementAnalysis instead
   final List<Element> caseElements =
       Dom4jUtils.elements(element(), XFormsConstants.XFORMS_CASE_QNAME);
   for (final Element caseElement : caseElements) {
     if (XFormsCaseControl.isDefaultSelected(caseElement)) {
       // Found first case with selected="true"
       return XFormsUtils.getElementId(caseElement);
     }
   }
   // Didn't find a case with selected="true" so return first case
   return XFormsUtils.getElementId(caseElements.get(0));
 }
コード例 #2
0
  // Test that xxf:attribute elements with @id and @for were created for
  @Test
  public void xxformsAttribute() {

    final Document document =
        Dom4jUtils.readFromURL(
            "oxf:/org/orbeon/oxf/xforms/processor/test-form.xml",
            XMLUtils.ParserConfiguration.PLAIN);
    final Metadata metadata = new Metadata();
    final Document annotatedDocument =
        new XBLBindings(new IndentedLogger(XFormsServer.logger, ""), null, metadata)
            .annotateShadowTree(document, "", false);
    final DocumentWrapper documentWrapper =
        new DocumentWrapper(annotatedDocument, null, XPathCache.getGlobalConfiguration());

    // Check there is an xxf:attribute for "html" with correct name
    List<Object> result =
        XPathCache.evaluate(
            documentWrapper,
            "//xxf:attribute[@for = 'html']",
            XFormsStaticStateImpl.BASIC_NAMESPACE_MAPPING(),
            null,
            null,
            null,
            null,
            null);

    assertNotNull(result);
    assertEquals(1, result.size());
    Element resultElement = (Element) ((NodeWrapper) result.get(0)).getUnderlyingNode();
    assertTrue(XFormsUtils.getElementId(resultElement).trim().length() > 0);
    assertEquals("lang", resultElement.attributeValue(XFormsConstants.NAME_QNAME));

    // Check there is an xxf:attribute for "span" with correct name
    result =
        XPathCache.evaluate(
            documentWrapper,
            "//xxf:attribute[@for = 'span']",
            XFormsStaticStateImpl.BASIC_NAMESPACE_MAPPING(),
            null,
            null,
            null,
            null,
            null);

    assertNotNull(result);
    assertEquals(1, result.size());
    resultElement = (Element) ((NodeWrapper) result.get(0)).getUnderlyingNode();
    assertTrue(XFormsUtils.getElementId(resultElement).trim().length() > 0);
    assertEquals("style", resultElement.attributeValue(XFormsConstants.NAME_QNAME));
  }