xsl-list
[Top] [All Lists]

RE: Problem setting variable from xsl:call-template

2005-03-03 10:40:55
You haven't shown us a source document. Does the Attribute element have a
child element called AUDIT_COLUMN? Perhaps you meant to write
select="'AUDIT_COLUMN'"?

Michael Kay
http://www.saxonica.com/



-----Original Message-----
From: lotoole [mailto:lotoole(_at_)page(_dot_)aiserv(_dot_)net] 
Sent: 03 March 2005 17:20
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Problem setting variable from xsl:call-template

I am having a problem setting a variable value with the 
results of a template
call.  I would like to pass a string value to a template and 
receive back a
string or nothing, then evaluate this value later for further 
conditional
processing.  I can see from my output listing that my 
template can detect the
string patterns, but I am not setting the variable value on return.  

I am using ant for build/run and the java libraries 
xalan-2.5.1.jar and
xercesImpl-2.5.0.jar for transformation and parsing.  I am 
seeking an XSLT 1.0
solution.

Thanks for any assistance

<?xml version="1.0"?>
<xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
 <xsl:output method="text" indent="yes" media-type="text/plain"/>
 
 <xsl:template match="/"><?xml version="1.0" encoding="UTF-8"?>
   <xsl:for-each select="ERwin4/Model/Entity_Groups/Entity">

     <!-- ignore any tables starting with '_' character as 
these are used for
comments on datamodel diagram -->
     <xsl:if test="not(starts-with(@Name,'_'))">
       <xsl:for-each select="Attribute_Groups/Attribute">

         <xsl:variable name="isAuditColumnName">
           <xsl:call-template name="is_audit_column">
             <xsl:with-param name="columnName" select="@Name"/>
           </xsl:call-template>
         </xsl:variable>
         <xsl:message>YYY<xsl:value-of
select="$isAuditColumnName"/>YYY</xsl:message>
   
         ...snip.

       </xsl:for-each>
     </xsl:if>
   </xsl:for-each>
 </xsl:template>
     
 <xsl:template name="is_audit_column">
   <xsl:param name="columnName" select="''"/>

   <!-- find audit columnNames that match a set of names -->
   <xsl:if test="string($columnName)='created_date'">
     <xsl:value-of select="AUDIT_COLUMN"/>
     <xsl:message>XXX<xsl:value-of 
select="$columnName"/>XXX</xsl:message>
   </xsl:if>
   <xsl:if test="string($columnName)='created_by_sak'">
     <xsl:value-of select="AUDIT_COLUMN"/>
     <xsl:message>XXX<xsl:value-of 
select="$columnName"/>XXX</xsl:message>
   </xsl:if>
 </xsl:template>
</xsl:stylesheet>

---------------------------------------------------------------------
Output during run
---------------------------------------------------------------------

[echo] converting xml export to Excel file named: 
REDS_Phase2_Comments.xls
[java] Input: XML (.\..\xml\datamodel\ReDS_Phase2_erwin_export.xml)
[java] Stylesheet: 
.\..\xsl\gen\excel\REDS_Phase2_DataDictionary_Comments.xsl
[java] Output: XLS (.\REDS_Phase2_DataDictionary_Comments.xls)

[java] Transforming...
[java] file:///...snip... Line #222; Column #14; YYYYYY
[java] file:///...snip... Line #222; Column #14; YYYYYY
...snip...
[java] file:///...snip... Line #222; Column #14; YYYYYY
[java] file:///...snip... Line #222; Column #14; YYYYYY
[java] file:///...snip... Line #299; Column #20; XXXcreated_dateXXX
[java] file:///...snip... Line #222; Column #14; YYYYYY
[java] file:///...snip... Line #304; Column #20; XXXcreated_by_sakXXX
[java] file:///...snip... Line #222; Column #14; YYYYYY
...snip...
[java] file:///...snip... Line #222; Column #14; YYYYYY
[java] file:///...snip... Line #222; Column #14; YYYYYY
[java] file:///...snip... Line #222; Column #14; YYYYYY
[java] file:///...snip... Line #299; Column #20; XXXcreated_dateXXX
[java] file:///...snip... Line #222; Column #14; YYYYYY
[java] file:///...snip... Line #304; Column #20; XXXcreated_by_sakXXX
[java] file:///...snip... Line #222; Column #14; YYYYYY
[java] file:///...snip... Line #222; Column #14; YYYYYY
...snip.

Thank you,

Laurence T. O'Toole

--
Absolute Internet Services (http://www.aiserv.net)

--
Absolute Internet Services (http://www.aiserv.net)


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--