This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
variable definition reuse
- From: "Laura Jenkins" <xsl_list at hotmail dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 22 Mar 2002 12:25:51 +0000
- Subject: [xsl] variable definition reuse
- Reply-to: xsl-list at lists dot mulberrytech dot com
i have got a doubt.. this is regarding making my XSL sheet more reusable.
i have got an xml file that looks like:
<ProductList>
<product id = "1">
<color>red</color>
<weight>23</weight>
<cost>150</cost>
<acceptance>90</acceptance>
<mnf-date>20032001</mnf-date>
<exp-date>20032002</exp-date>
<lable-design>XYZ</lable-design>
<mkt-agncy>ABC</mkt-agncy>
<serial-id>11111</serial-id>
<order-qty>90</order-qty>
<re-order-level>10</re-order-level>
</product>
<product is = "2">
<color>blue</color>
<weight>25</weight>
<cost>150</cost>
<acceptance>80</acceptance>
<mnf-date>20032001</mnf-date>
<exp-date>20032002</exp-date>
<lable-design>ZZ</lable-design>
<mkt-agncy>AA</mkt-agncy>
<serial-id>22222</serial-id>
<order-qty>70</order-qty>
<re-order-level>10</re-order-level>
</product>
<product>
<product id = "3">
<color>yellow</color>
<weight>30</weight>
<cost>200</cost>
<acceptance>50</acceptance>
<mnf-date>20032001</mnf-date>
<exp-date>20032002</exp-date>
<lable-design>PQR</lable-design>
<mkt-agncy>ABC</mkt-agncy>
<serial-id>33333</serial-id>
<order-qty>50</order-qty>
<re-order-level>10</re-order-level>
</product>
<product>
</ProductList>
and i have to develop the XSL to produce 20 different file formats.. some of
them text, some xml and the others HTML. They vary by the way the data is
arrainged.
now at the moment,
what i am doing is that in all the 20 XSL sheets, I am defining these
variables like below..
<xsl:template match="//programme">
<!-- VARIABLE DECLARATION -->
<xsl:variable name = "color" select = "color">
<xsl:variable name = "weight" select = "weight">
<xsl:variable name = "cost" select = "cost">
<xsl:variable name = "acceptance" select = "acceptance">
<xsl:variable name = "mnf-date" select = "mnf-date">
<xsl:variable name = "exp-date" select = "exp-date">
<xsl:variable name = "lable-design" select = "lable-design">
<xsl:variable name = "mkt-agncy" select = "mkt-agncy">
<xsl:variable name = "serial-id" select = "serial-id">
<xsl:variable name = "order-qty" select = "order-qty">
<xsl:variable name = "re-order-level" select = "re-order-level">
.<!-- VARIABLE DECLARATION ENDS -->
.
.----- do some formating on these variables and display ( This block IS
THE ONLY THING THAT CHANGES IN ALL THE 20 FILES ) ----------
.
</xsl:template>
This block remains same in all the 20 files. Now what i wanted to do is that
define these variables in a separate file so that all the 20 XSL files can
access/share these variables.
I am not able to implement this idea. Can some one be able to tell me if
1. it is possible to do define element specific variables in a different
file??
2. it is the right approach to do it that way??
I want to essentially remove that variable declaration block and place it in
a different file for reuse.
cheers
laura
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list