Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XSL using incoming XML for calculations

From: Eadro@-----------.---------.---
To: NULL
Date: 2/8/2005 7:01:00 AM
I'm trying to convert incoming xml data which looks like this:

<Anfrage><Minimum><Wert1>0</Wert1><Wert2>5</Wert2></Minimum></Anfrage>

to this XML data

<Antwort><Ergebniss>0</Ergebniss></Antwort>

Using a XSL Stylesheet. The stylesheet should find the Minimum or the 
Maximum of the two Numbers, whichever is needed. The Stylesheet looks like 
this:

<xsl:stylesheet version="1.1" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml"/>
  <xsl:template match="/">
    <xsl:element name="Antwort">
      <xsl:element name="Ergebniss">
        <xsl:for-each select="Minimum">
          <xsl:choose>
            <xsl:when test="Wert1>=Wert2">
              <xsl:value-of select="Wert2"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="Wert1"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:for-each>
        <xsl:for-each select="Maximum">
          <xsl:choose>
             <xsl:when test="Wert1>=Wert2">
               <xsl:value-of select="Wert1"/>
             </xsl:when>
             <xsl:otherwise>
               <xsl:value-of select="Wert2"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:for-each>
      </xsl:element>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>

And finally the ASP (Javascript) Code which sends the Request. It recieves 
the xml data just fine, but it fails to respond.

  serverURL = "http://" + Request.ServerVariables("SERVER_NAME") + 
"/ASPTest/";
  
  //Get XML-request
  var xmlRequest = Server.CreateObject("Microsoft.XMLDOM");
  xmlRequest.async = false;
  xmlRequest.load(Request);
  //xmlRequest.load(serverURL + "test.xml");
  
  //Load Transformationpage
  var transformExtrem = new ActiveXObject("Microsoft.XMLDOM");
  transformExtrem.async = false;
  transformExtrem.load(serverURL + "Extremwert.xsl");
  //transformExtrem.load(ServerMapPath("ASPTest/Extremwert.xsl"));
  
  //Transform
  var xmlResponse = Server.CreateObject("Microsoft.XMLDOM");
  xmlResponse.async = false;
  xmlResponse.transformNodeToObject(transformExtrem, xmlResponse);
  
  //sende XML-Answer
  Response.ContentType="text/xml";
  xmlResponse.save(Response);


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent