RE: [xml] XSLTPROC is slow along with XSLT

Hi Vikrant,

From: Vikrant Rathore 
i have written an XSL file an also developed a small 
application to convert 
XML to XSLT. There has been real performance issue with XSLT. 

Your XSL is severely broken. Let me try to explain why...

<xsl:stylesheet version='1.0' 
xmlns:xsl='' >
<xsl:output method="text"/>

<xsl:for-each select="//item">

This traverses the whole tree

<xsl:value-of select="//job_id"/>

So does this


so do the rest of these //s

So what you're getting is "Search the entire document for nodes called
"data", and for each one we find, search the entire document for elements
called "job_id", give me the text value of the first one, etc..."

This is extremely inefficient, and is also probably not what you want.

Assuming that your document looks something like this:


try changing your stylesheet to 
<xsl:for-each select="item">
  <xsl:value-of select="job_id"/>
  <xsl:value-of select="customer_code"/>

Or at least changing the //s to .//s if there really is a need to search the
whole subtree. Adding the . means you're starting your search from the
currently selected node, and not from the root.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]