コード例 #1
0
  /**
   * Transforms an xml document based on the xsl deign element specified.
   *
   * @param xmlData
   * @param sDesignElement
   * @return a transformed lock of XML
   */
  public StringBuilder xmlTransform(StringBuilder xmlData, String sDesignElement) {

    DesignElement de = getDesignObject(sDesignElement, DesignElement.DESIGN_TYPE_RESOURCE);

    if (de == null) {
      // get the xml columns
      String sColumns[] = TableManager.getXMLColumnNames(xmlData);
      // for(int i=0; i<sColumns.length; i++) System.out.println(sColumns[i]);
      // make a stylesheet and save it to the design collection
      // if it saved ok, then recall this method, cause we'll find the sheet next time
      if (saveXSLDesignElement(sDesignElement, sColumns))
        return xmlTransform(xmlData, sDesignElement);

      return null;
    }
    // maybe check the contenttype is xsl ??
    String sXML = null;
    try {
      sXML = new String(de.getContent(), "UTF-8");
      if (sXML != null && (sXML.indexOf("<P@") >= 0 || sXML.indexOf("<p@") >= 0)) {
        // FIXME parse out the <P@ST tags
        HTMLDocument docHTML = new HTMLDocument(this);
        docHTML.designObject = de;
        docHTML.rPath = new RequestPath(getRequestPath().getFullPath());
        docHTML.setParameters(getRequestPath().Parameters);
        docHTML.prepare();
        docHTML.renderDocument(false);
        sXML = new String(docHTML.getContent(), "UTF-8");
      }
    } catch (Exception e) {
    }
    StringBuilder xslData = new StringBuilder(sXML);
    return Util.xmlTransform(m_SysCtx, xmlData, xslData);
  }
コード例 #2
0
 /**
  * Sets the design element that will be returned to the client
  *
  * @param doc
  * @param de
  */
 public void setDesignObject(HTMLDocument doc, DesignElement de) {
   doc.designObject = de;
   doc.removeParsedParts();
   doc.prepare();
 }