Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT - Simplifying a template

Status
Not open for further replies.

ddrillich

Technical User
Jun 11, 2003
546
US
Good Day,

The following template works just fine -

Code:
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
  xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL]
  xmlns:autn="[URL unfurl="true"]http://schemas.autonomy.com/aci/"[/URL]
  xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL]
  xmlns:dt="[URL unfurl="true"]http://xsltsl.org/date-time">[/URL]


<xsl:import href="stdlib.xsl"/>
<xsl:output method="xml"/>
<xsl:strip-space elements="*"/>


 <xsl:template match="warning">
     <warning><xsl:value-of select="."/></warning>
 </xsl:template>

 <xsl:template match="value">
  <value count="{@count}"><xsl:value-of select="."/></value>
 </xsl:template>

 <xsl:template match="field">


   <xsl:variable name="name"            select="name"/>
   <!-- Convert DOCUMENT/PI_PERSON -> PI_PERSON -->
   <!-- 10 is the length of "DOCUMENT/" -->
   <xsl:variable name="name2"            select="substring($name,10)"/>

   <xsl:variable name="total_values"    select="total_values"/>

   <result-row name="{$name2}" total="{$total_values}">

   <xsl:apply-templates select="value"/>


  </result-row>
 </xsl:template>


<xsl:template match="/">

<parametric-results>
  <status><xsl:value-of select="autnresponse/response" /></status>

     <!-- Display multiple warnings if any -->
     <xsl:apply-templates select="autnresponse/responsedata/warning"/>

     <xsl:apply-templates select="autnresponse/responsedata/field"/>


</parametric-results>

 </xsl:template>


</xsl:stylesheet>

I wonder if there is a way to eliminate the following -

Code:
<xsl:template match="/">

and its closing part.

Regards,
Dan
 
Why would you like to eliminate that? You can, but instead of that, it is replaced by something of the same purpose to getting the root parametric-result in place.
 
I thought that maybe it's not needed ;-). Thank you tsuji for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top