[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: merging two templates with starts-with same name
I can not say I understand exactly what you are trying to achieve, perhaps you can supply an example of your xml and how you are calling each of the templates. However, your consolidated template might look like: <xsl:template match="*[substring(name(),1,5)='refDB']" mode="refDB"> <xsl:param name="refDB"/> <xsl:choose> <xsl:when test="normalize-space($refDB) != '' "><xsl:value-of select="$refDB"/></xsl:when> <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> </xsl:choose> </xsl:template> Regards Bryan -----Original Message----- From: "Braumüller, Hans" [mailto:H.Braumueller@xxxxxxxxxxxx] Sent: 29 April 2003 10:38 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: merging two templates with starts-with same name Hello friends, small problem but i cannot get the solution i have two similar templates: <xsl:template match="refDB1" mode="refDB"> <xsl:param name="refDB"/> <xsl:choose> <xsl:when test="normalize-space($refDB) != '' "><xsl:value-of select="$refDB"/></xsl:when> <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="refDB2" mode="refDB"> <xsl:param name="refDB" /> <xsl:choose> <xsl:when test="normalize-space($refDB) != '' "><xsl:value-of select="$refDB"/></xsl:when> <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> </xsl:choose> </xsl:template> i am trying to do one for all nodes that starts-with refDB like pseudo-code: <xsl:template match="*[name() = starts-with(refDB, *)]" mode="refDB"> <xsl:param name="refDB" /> <xsl:choose> <xsl:when test="normalize-space($refDB) != '' "><xsl:value-of select="$refDB"/></xsl:when> <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> </xsl:choose> </xsl:template> As second optimization i am trying to figure out how i can select a variable instead a to pass a parameter with the selecting node, because i am matching node refDB1 on my properties.xml (over document() ) so i know that name to select it igual on my source.xml, where if it is empty or not exists, i output the value of my properties.xml. Thanks, Hans Braumüller -- + -- Mail Art Not War http://crosses.net XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list Visit our website at http://www.rm.com This message is confidential. You should not copy it or disclose its contents to anyone. You may use and apply the information only for the intended purpose. Internet communications are not secure and therefore RM does not accept legal responsibility for the contents of this message. Any views or opinions presented are only those of the author and not those of RM. If this email has come to you in error please delete it and any attachments. Please note that RM may intercept incoming and outgoing e-mail communications. This email has been scanned for viruses by Trend ScanMail. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|