Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 11th, 2008, 02:56 PM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default performance issue with the xsl given here

we are working on a SOA appliance. we get a terrible performance impact if we use the following xsl in our application which will be running in the appliance.

Not considering the appliance specific variables used in this xsl.. is there any fine tuning that we can make in the xsl so that the performance can be increased.

also is there any tool to compute complexity of a xsl. how will i find out if there is any danger of memory leakage in this xsl?


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:func="http://exslt.org/functions" xmlns:date="http://exslt.org/dates-and-times" xmlns:v002="http://www.company.com/schema/eih/LoggingCommonTypes/v001" xmlns:cihfn="http://www.cih.com/xslt/extensions" extension-element-prefixes="dp func cihfn">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="/">
        <xsl:variable name="currMilli" select="dp:time-value()"/>
        <xsl:variable name="timeElapsed" select="dp:variable('var://service/time-elapsed')"/>
        <xsl:variable name="actualStartTime" select="number($currMilli - $timeElapsed)"/>
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.company.com/wsdl/eih/EnterpriseLogging/V1_0" xmlns:v002="http://www.company.com/schema/eih/LoggingCommonTypes/V001">
            <soapenv:Header/>
            <soapenv:Body>
                <v1:LogTransaction>
                    <v1:applicationDetail>
                        <v002:name>app01</v002:name>
                        <v002:role>intermediary</v002:role>
                        <v002:serverName>
                            <xsl:value-of select="concat(dp:variable('var://service/system/ident')/identification/device-name,':',dp:variable('var://service/domain-name'))"/>
                        </v002:serverName>
                        <v002:datacenter/>
                    </v1:applicationDetail>
                    <xsl:variable name="RequestHeader" select="dp:variable('var://context/cih/RequestHeader')"/>
                    <xsl:variable name="verbosityStatus" select="string(cihfn:getVerbosityStatus())"/>
                    <xsl:choose>
                        <xsl:when test="dp:variable('var://context/log/transactionStatus') = 'failure'">
                            <v1:transactionDetailList xmlns:v1="http://www.company.com/wsdl/eih/EnterpriseLogging/V1_0" xmlns:v002="http://www.company.com/schema/eih/LoggingCommonTypes/V001">
                                <v002:transactionName>
                                    <xsl:value-of select="dp:variable('var://context/cih/resource')"/>
                                </v002:transactionName>
                                <v002:correlation>
                                    <v002:traceID>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='traceId']"/>
                                    </v002:traceID>
                                    <v002:createdTraceID>false</v002:createdTraceID>
                                    <v002:transactionID>
                                        <xsl:value-of select="concat(dp:variable('var://service/transaction-id'), ':',$RequestHeader//*[local-name()='traceId'])"/>
                                    </v002:transactionID>
                                    <v002:transactionLevel>main</v002:transactionLevel>
                                </v002:correlation>
                                <v002:systems>
                                    <v002:consumer>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='component']"/>
                                    </v002:consumer>
                                    <v002:provider>
                                        <xsl:value-of select="dp:variable('var://context/cih/config')//application"/>
                                    </v002:provider>
                                </v002:systems>
                                <v002:transactionTimes>
                                    <v002:start>
                                        <xsl:value-of select="string(cihfn:getGMTtime($actualStartTime)) "/>
                                    </v002:start>
                                    <v002:end>
                                        <xsl:value-of select="string(cihfn:getGMTtime(number($actualStar tTime + $timeElapsed)))"/>
                                    </v002:end>
                                </v002:transactionTimes>
                                <v002:result>
                                    <v002:status>
                                    failure
                                </v002:status>
                                    <v002:errorReason>
                                        <xsl:value-of select=".//*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Fault']/*[local-name()='detail']/*[local-name()='FaultDetail']/*[local-name()='listOfExceptions']/*[local-name()='Exception']/*[local-name()='detail']/*[local-name()='code']"/>
                                    </v002:errorReason>
                                    <v002:errorDescription>
                                        <xsl:value-of select=".//*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Fault']/*[local-name()='detail']/*[local-name()='FaultDetail']/*[local-name()='listOfExceptions']/*[local-name()='Exception']/*[local-name()='detail']/*[local-name()='message']"/>
                                    </v002:errorDescription>
                                </v002:result>
                                <v002:miscData>
                                    <v002:channel>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='channel']"/>
                                    </v002:channel>
                                    <v002:companyNumber/>
                                    <v002:userId>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='userId']"/>
                                    </v002:userId>
                                    <v002:costCenter/>
                                    <v002:state/>
                                    <v002:triggerEvent/>
                                    <v002:additionalInfo/>
                                </v002:miscData>
                                <v002:protocol>
                                    <v002:message>
                                        <xsl:value-of select="dp:variable('var://context/log/targetMessageType')"/>
                                    </v002:message>
                                    <v002:transport>
                                        <xsl:value-of select="dp:variable('var://service/protocol')"/>
                                    </v002:transport>
                                </v002:protocol>
                                <v002:verbosityData>
                                    <xsl:choose>
                                        <xsl:when test="$verbosityStatus = 'true'">
                                            <v002:request>
                                                <xsl:value-of disable-output-escaping="yes" select="string('&lt;![CDATA[')"/>
                                                <xsl:copy-of select="dp:variable('var://context/INPUT')"/>
                                                <xsl:value-of disable-output-escaping="yes" select="string(']]&gt;')"/>
                                            </v002:request>
                                            <v002:response>
                                                <xsl:value-of disable-output-escaping="yes" select="string('&lt;![CDATA[')"/>
                                                <xsl:copy-of select="."/>
                                                <xsl:value-of disable-output-escaping="yes" select="string(']]&gt;')"/>
                                            </v002:response>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <v002:request>
                                                <xsl:value-of select="string-length(string(dp:variable('var://context/INPUT')))"/>
                                            </v002:request>
                                            <v002:response>
                                                <xsl:copy-of select="string-length(string(.))"/>
                                            </v002:response>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </v002:verbosityData>
                            </v1:transactionDetailList>
                        </xsl:when>
                        <xsl:otherwise>
                            <v1:transactionDetailList xmlns:v1="http://www.company.com/wsdl/eih/EnterpriseLogging/V1_0" xmlns:v002="http://www.company.com/schema/eih/LoggingCommonTypes/V001">
                                <v002:transactionName>
                                    <xsl:value-of select="dp:variable('var://context/cih/resource')"/>
                                </v002:transactionName>
                                <v002:correlation>
                                    <v002:traceID>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='traceId']"/>
                                    </v002:traceID>
                                    <v002:createdTraceID>false</v002:createdTraceID>
                                    <v002:transactionID>
                                        <xsl:value-of select="concat(dp:variable('var://service/transaction-id'), ':',$RequestHeader//*[local-name()='traceId'])"/>
                                    </v002:transactionID>
                                    <v002:transactionLevel>child</v002:transactionLevel>
                                </v002:correlation>
                                <v002:systems>
                                    <v002:consumer>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='component']"/>
                                    </v002:consumer>
                                    <v002:provider>
                                        <xsl:value-of select="dp:variable('var://context/cih/config')//application"/>
                                    </v002:provider>
                                </v002:systems>
                                <v002:transactionTimes>
                                    <v002:start>
                                        <xsl:value-of select="string(cihfn:getGMTtime(number($actualStar tTime + dp:variable('var://context/log/targetRequestTime'))))"/>
                                    </v002:start>
                                    <v002:end>
                                        <xsl:value-of select="string(cihfn:getGMTtime(number($actualStar tTime + dp:variable('var://service/time-response-complete'))))"/>
                                    </v002:end>
                                </v002:transactionTimes>
                                <v002:result>
                                    <v002:status>success</v002:status>
                                </v002:result>
                                <v002:miscData>
                                    <v002:channel>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='channel']"/>
                                    </v002:channel>
                                    <v002:companyNumber/>
                                    <v002:userId>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='userId']"/>
                                    </v002:userId>
                                    <v002:costCenter/>
                                    <v002:state/>
                                    <v002:triggerEvent/>
                                    <v002:additionalInfo/>
                                </v002:miscData>
                                <v002:protocol>
                                    <v002:message>
                                        <xsl:value-of select="dp:variable('var://context/log/targetMessageType')"/>
                                    </v002:message>
                                    <v002:transport>
                                        <xsl:value-of select="dp:variable('var://service/protocol')"/>
                                    </v002:transport>
                                </v002:protocol>
                                <v002:verbosityData>
                                    <xsl:choose>
                                        <xsl:when test="$verbosityStatus = 'true'">
                                            <v002:request>
                                                <xsl:value-of disable-output-escaping="yes" select="string('&lt;![CDATA[')"/>
                                                <xsl:copy-of select="dp:variable('var://context/log/targetRequest')"/>
                                                <xsl:value-of disable-output-escaping="yes" select="string(']]&gt;')"/>
                                            </v002:request>
                                            <v002:response>
                                                <xsl:value-of disable-output-escaping="yes" select="string('&lt;![CDATA[')"/>
                                                <xsl:copy-of select="dp:variable('var://context/INPUT')"/>
                                                <xsl:value-of disable-output-escaping="yes" select="string(']]&gt;')"/>
                                            </v002:response>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <v002:request>
                                                <xsl:value-of select="string-length(string(dp:variable('var://context/log/targetRequest')))"/>
                                            </v002:request>
                                            <v002:response>
                                                <xsl:copy-of select="string-length(string(dp:variable('var://context/INPUT')))"/>
                                            </v002:response>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </v002:verbosityData>
                            </v1:transactionDetailList>
                            <v1:transactionDetailList xmlns:v1="http://www.company.com/wsdl/eih/EnterpriseLogging/V1_0" xmlns:v002="http://www.company.com/schema/eih/LoggingCommonTypes/V001">
                                <v002:transactionName>
                                    <xsl:value-of select="dp:variable('var://context/cih/resource')"/>
                                </v002:transactionName>
                                <v002:correlation>
                                    <v002:traceID>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='traceId']"/>
                                    </v002:traceID>
                                    <v002:createdTraceID>false</v002:createdTraceID>
                                    <v002:transactionID>
                                        <xsl:value-of select="concat(dp:variable('var://service/transaction-id'), ':',$RequestHeader//*[local-name()='traceId'])"/>
                                    </v002:transactionID>
                                    <v002:transactionLevel>main</v002:transactionLevel>
                                </v002:correlation>
                                <v002:systems>
                                    <v002:consumer>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='component']"/>
                                    </v002:consumer>
                                    <v002:provider>
                                        <xsl:value-of select="dp:variable('var://context/cih/config')//application"/>
                                    </v002:provider>
                                </v002:systems>
                                <v002:transactionTimes>
                                    <v002:start>
                                        <xsl:value-of select="string(cihfn:getGMTtime($actualStartTime)) "/>
                                    </v002:start>
                                    <v002:end>
                                        <xsl:value-of select="string(cihfn:getGMTtime(number($actualStar tTime + $timeElapsed)))"/>
                                    </v002:end>
                                </v002:transactionTimes>
                                <v002:result>
                                    <v002:status>success</v002:status>
                                </v002:result>
                                <v002:miscData>
                                    <v002:channel>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='channel']"/>
                                    </v002:channel>
                                    <v002:companyNumber/>
                                    <v002:userId>
                                        <xsl:value-of select="$RequestHeader//*[local-name()='userId']"/>
                                    </v002:userId>
                                    <v002:costCenter/>
                                    <v002:state/>
                                    <v002:triggerEvent/>
                                    <v002:additionalInfo/>
                                </v002:miscData>
                                <v002:protocol>
                                    <v002:message>
                                        <xsl:value-of select="dp:variable('var://context/log/clientMessageType')"/>
                                    </v002:message>
                                    <v002:transport>
                                        <xsl:value-of select="dp:variable('var://service/protocol')"/>
                                    </v002:transport>
                                </v002:protocol>
                                <v002:verbosityData>
                                    <xsl:choose>
                                        <xsl:when test="$verbosityStatus = 'true'">
                                            <v002:request>
                                            &
Reply With Quote
  #2 (permalink)  
Old July 11th, 2008, 05:24 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I can't see any obvious performance gotchas in this code, it's not very pretty code and there are lots of calls to extension functions that could be doing unknown things, but the navigation logic looks pretty straightforward. It might be a problem that's specific to your particular XSLT processor, or something about the way you are using it. Is there a large source document? How does the performance vary with the size of the source document - do some experiments. Try removing parts of the stylesheet code, piece by piece, to see whether this identifies the part that's causing the problems.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old July 11th, 2008, 07:44 PM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default

this xsl creates a log message in soap/xml format and this xml message is sent to another webservice which will do the actual logging in linux box. the verbosity data tag shown below carries the request and response xmls of a particular transaction. there are four such xmls (2 req 2 resp) embedded in the log message. will this be a reason? each xml is hardly 2000 bytes long. also the documents we open up in this xsl is pretty small. so did this explanation gave any input to you to answer why there may be a performance fall back?

you can see certain parts in the code are repeated. i can avaoid this by using another template which could create the log message for me. is there any problem if i pass lot of parameters to a template? (say a 2000 byte parameter)

this is the area where in we are embedding requests/response of a

<v002:verbosityData>
                                    <xsl:choose>
                                        <xsl:when test="$verbosityStatus = 'true'">
                                            <v002:request>
                                                <xsl:value-of disable-output-escaping="yes" select="string('&lt;![CDATA[')"/>
                                                <xsl:copy-of select="dp:variable('var://context/log/targetRequest')"/>
                                                <xsl:value-of disable-output-escaping="yes" select="string(']]&gt;')"/>
                                            </v002:request>
                                            <v002:response>
                                                <xsl:value-of disable-output-escaping="yes" select="string('&lt;![CDATA[')"/>
                                                <xsl:copy-of select="dp:variable('var://context/INPUT')"/>
                                                <xsl:value-of disable-output-escaping="yes" select="string(']]&gt;')"/>
                                            </v002:response>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <v002:request>
                                                <xsl:value-of select="string-length(string(dp:variable('var://context/log/targetRequest')))"/>
                                            </v002:request>
                                            <v002:response>
                                                <xsl:copy-of select="string-length(string(dp:variable('var://context/INPUT')))"/>
                                            </v002:response>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </v002:verbosityData>
Reply With Quote
  #4 (permalink)  
Old July 12th, 2008, 02:23 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>so did this explanation gave any input to you to answer why there may be a performance fall back?

It tends to confirm my suspicion that the cost is not in the XSLT code, but in the external services it is calling upon.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #5 (permalink)  
Old July 12th, 2008, 07:28 AM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default

what do you mean by external services here? i didnt understand...

Reply With Quote
  #6 (permalink)  
Old July 12th, 2008, 07:58 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well the transformation uses stuff like dp:variable('var://context/cih/RequestHeader'), what does that do?

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #7 (permalink)  
Old July 12th, 2008, 08:01 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You say for example

>this xml message is sent to another webservice

But I'm sorry, I can only make guesses. I know nothing about the products you are using or the environment you are running in. One can't debug performance issues just by staring at them.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #8 (permalink)  
Old July 12th, 2008, 08:35 AM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default

well I am truely concerned about the performance set back that this xsl may bring. the external web service is invoked asynchronously however. Fine Kay. Thanks for the reply.

Reply With Quote
  #9 (permalink)  
Old July 12th, 2008, 08:48 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It doesn't matter if it's asynchronous or not, if it's returning a value to the transformation process then it must wait until it's received before it can continue.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #10 (permalink)  
Old July 12th, 2008, 10:10 AM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default

thats true. but it is just a fire and forget process. the result of the transformation is sent to the web service and thats it. the transaction comes to end.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
performance issue keyvanjan Classic ASP Basics 0 May 23rd, 2006 10:57 AM
Performance Issue of Execution bjohnjebastin ASP.NET 1.0 and 1.1 Basics 1 November 14th, 2005 11:18 AM
issue of performance alyeng2000 SQL Server 2000 6 August 20th, 2004 01:17 PM
Performance issue deyakhatib SQL Server 2000 2 June 21st, 2004 10:47 PM



All times are GMT -4. The time now is 01:21 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.