Exemple #1
0
  private String getInlineJavaScript(Node embed) throws XFormsException {
    // fetch style element(s) from Node to embed
    String javaScriptCode = "";
    if (embed instanceof Document) {
      embed = ((Document) embed).getDocumentElement();
    }

    // Get all inline script ignoring script that folllows a xforms:node
    List result =
        XPathUtil.evaluate(
            (Element) embed,
            "//*[not( namespace-uri()='http://www.w3.org/2002/xforms' )]/*[(@type='text/javascript') and (not(boolean(@src)))]");
    if (result.size() == 0) {
      return null;
    }
    for (int i = 0; i < result.size(); i++) {
      Object item = result.get(i);
      if (result.get(i) instanceof NodeWrapper) {
        NodeWrapper wrapper = (NodeWrapper) item;
        if (!"action".equals(((NodeWrapper) item).getParent().getLocalPart())) {
          Node n = (Node) wrapper.getUnderlyingNode();
          javaScriptCode += DOMUtil.getTextNodeAsString(n);
        }
      }
    }

    return javaScriptCode;
  }
Exemple #2
0
 private String getInlineCSS(Node embed) throws XFormsException {
   // fetch style element(s) from Node to embed
   String cssRules = "";
   if (embed instanceof Document) {
     embed = ((Document) embed).getDocumentElement();
   }
   List result =
       XPathUtil.evaluate((Element) embed, "//*[@type='text/css' and (not(boolean(@href)))]");
   if (result.size() == 0) {
     return null;
   }
   for (int i = 0; i < result.size(); i++) {
     Object item = result.get(i);
     if (result.get(i) instanceof NodeWrapper) {
       NodeWrapper wrapper = (NodeWrapper) item;
       Node n = (Node) wrapper.getUnderlyingNode();
       cssRules += DOMUtil.getTextNodeAsString(n);
     }
   }
   return cssRules;
 }