Hello,

I have a problem trying to transform a SOAPMessage using a 
dom4j.DocumentResult

I do not have any problem to transform the SOAPMessage without dom4j 
using xalan directly (CLI or via JAXP); however I am not an expert in 
XSLT and maybe dom4j is more restrict?

Here is part of the code:

   private void buildUDKEntity(SOAPMessage soapUDKQuery) {
     try {
       Source source = soapUDKQuery.getSOAPPart().getContent();
       Result result = transformAttribute2Table(source);
   ....
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE web-app PUBLIC
	"-//disy Informationsysteme//SOAP-UDK-Query 1.1//EN"
	"http://www.disy.net/dtd/cadenza/udk/soap-udk-query_1_1.dtd";>
	-->
<!DOCTYPE udk PUBLIC
	"-//disy Informationsysteme//SOAP-UDK-Query 1.1//EN"
	"http://zeus.disy.net:1234/~udk/soap-udk-query_1_1.dtd";>

<!-- Im Folgenden darf immer nur eine Object-Klassenspez. Anfrage formuliert werden. -->

<udk>
	<attribute-query>
    <object obj_desc="obj_desc_test" obj_name="obj_name_test">

      <data base="testbase" description="testdescription">
        <para parameter="testpara" unit="testunit"/>
      </data>
<!--
      <geo buildscale="" coord="" data_base="" description="" method="" pas_exact="" quality="" rec_exact="" rec_grade="" special_base="" subject_data="">
        <map map_name="" map_no=""/>
        <keyc subject_cat=""/>
        <scale scale=""/>
        <symc symbol_cat=""/>
      </geo>
-->
<!--
      <literatur autor="" base="" description="" doc_info="" isbn="" loc="" publish_in="" publish_loc="" publish_year="" publisher="" publishing="" sides="" typ="" volume=""/>
-->
<!--
      <project description="" leader="" member=""/>
-->
<!--
      <serv base="" description="" environment="" history="">
        <typ typ=""/>
      </serv>
-->

      <keyword name="Schlagwort"/>
      
      <env_class name="Umweltklassifikation"/>

      <address firstname="" institution="" name="">
        <keyword name="SchlagwortAddresse"/>
      </address>

      <info_impart name="Weitergabe an"/>
      
      <spatial-condition consider-coordinates="1" hierarchy-flag="1" place-disjunction="OR">
        <region>Elbe</region>
        <place>
          <location-code>001</location-code>
        </place>
      </spatial-condition>
      
      <temporal-condition time-interval-flag="3">
        <beginning-date>19901212</beginning-date>
        <ending-date>20021212</ending-date>
      </temporal-condition>
    </object>
	</attribute-query>
</udk>

<?xml version="1.0" encoding="ISO-8859-1"?> 
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
  xmlns:xalan="http://xml.apache.org/xslt";>

<!-- Dieses Stylesheet transformiert die anwenderfreundlichen Attributnamen aus 
     "-//disy Informationsysteme//SOAP-UDK-Query 1.1//EN" "http://www.disy.net/dtd/cadenza/udk/soap-udk-query_1_1.dtd";
     in die Technischen Namen der Datenbanktabellen um sie in der DB-Schicht einfacher auf DBDescriptions abbilden zu können. 
-->

<xsl:output
  method="xml"
  encoding="UTF-8"
  indent="yes"
  xalan:indent-amount="2"
/>

<xsl:template match="udk/attribute-query">
  <xsl:apply-templates select="object"/>
</xsl:template>

<xsl:template match="object">
<!--  <t01_object>
    <xsl:call-template name="copy-attributes"/>
    <xsl:apply-templates select="temporal-condition" mode="attribute-copy"/>
    <xsl:apply-templates select="keyword"/>
  </t01_object>
  -->
  <xsl:apply-templates select="data | data/* | geo | geo/* | literatur | project | serv | serv/*"/>
  <!--
  <xsl:apply-templates select="env_class"/>
  <xsl:apply-templates select="address"/>
  <xsl:apply-templates select="spatial-condition"/>
  -->
</xsl:template>

<!--<!ELEMENT temporal-condition (beginning-date?, ending-date?)>
<xsl:template match="object/temporal-condition" mode="attribute-copy">
  <xsl:call-template name="copy-attributes"/>
  <xsl:attribute name="time_from">
    <xsl:value-of select="beginning-date"/>
  </xsl:attribute>
  <xsl:attribute name="time_to">
    <xsl:value-of select="ending-date"/>
  </xsl:attribute>
</xsl:template>
-->

<xsl:template match="object/data | object/data/* | object/geo | object/geo/* | object/literatur | object/project | object/serv | object/serv/*">
  <xsl:call-template name="rename-element-with-prefix">
    <xsl:with-param name="prefix" select="'t011_obj_'"/>
  </xsl:call-template>
</xsl:template>
<!--
<xsl:template match="object/address">
  <t02_address>
    <xsl:call-template name="copy-attributes"/>
    <xsl:apply-templates select="keyword"/>
  </t02_address>
</xsl:template>

<xsl:template match="object/info_impart">
  <xsl:call-template name="rename-element-with-prefix">
    <xsl:with-param name="prefix" select="'t014_'"/>
  </xsl:call-template>
</xsl:template>

<xsl:template match="object/spatial-condition">
  <t019_coordinates>
    <xsl:attribute name="bezug">
      <xsl:value-of select="./@region"/>
    </xsl:attribute>
  </t019_coordinates>
  <t011_township>
    <xsl:attribute name="township_no">
      <xsl:value-of select="./place/@location-code"/>
    </xsl:attribute>  
  </t011_township>
</xsl:template>
-->
<xsl:template match="keyword">
  <t04_search>
    <xsl:call-template name="copy-attributes"/>
  </t04_search>
</xsl:template>

<!-- 
  Benenne element um, indem ein Prefix vorabgestelt wird
  Falls der VorVorgaenger "object" ist, wird der Prefix aus dem uebergebenen Prefix 
  und dem Namen des Vorgängers zusammengesetzt
-->
<xsl:template name="rename-element-with-prefix">
<xsl:param name="prefix"/>
<xsl:param name="table-name" select='concat($prefix, name(.))'/>
<xsl:choose>
  <xsl:when test="name(../..)='object'">
    <xsl:element name="{concat($prefix, name(..), '_', name(.))}">
      <!--<xsl:call-template name="copy-attributes"/>-->
    </xsl:element>
  </xsl:when>
  <xsl:otherwise>
    <xsl:element name="{$table-name}">
      <!--<xsl:call-template name="copy-attributes"/>-->
    </xsl:element>
  </xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
<xsl:template name="copy-attributes">
  <xsl:for-each select="@*">
    <xsl:attribute name="{name(.)}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:for-each>
</xsl:template>
-->
</xsl:stylesheet> 

Reply via email to