如何使用xsl将xml转换后输出xml
有一个customer.xml文件
<?xml version="1.0" encoding="gb2312"?>
<?xml:stylesheet type="text/xsl" href="order.xsl"?>
<root caption="客户" id="root">
<L0 caption="湖北经销商" id="31" >
<L1 caption="武汉" id="135" />
<L1 caption="黄石" id="1664" />
</L0>
<L0 caption="广东经销商" id="67" >
<L1 caption="广州" id="69" />
<L1 caption="深圳" id="89" />
<L1 caption="东莞" id="90" />
</L0>
</root>
现在要用一个order.xsl文件把上面的xml中的每个节点添加一个属性orderID,变成这样:
<?xml version="1.0" encoding="gb2312"?>
<?xml:stylesheet type="text/xsl" href="order.xsl"?>
<root caption="客户" id="root">
<L0 caption="湖北经销商" id="31" orderID="1">
<L1 caption="武汉" id="135" orderID="1"/>
<L1 caption="黄石" id="1664" orderID="0"/>
</L0>
<L0 caption="广东经销商" id="67" orderID="0">
<L1 caption="广州" id="69" orderID="2"/>
<L1 caption="深圳" id="89" orderID="0"/>
<L1 caption="东莞" id="90" orderID="1"/>
</L0>
</root>
而且所有的orderID属性值都是从数组中得到:
order=[1,0];
order0=[1,0];
order1=[0,2,1];
其中数组order 的长度和customer.xml中L0节点的个数是一样的,每个数组元素对应L0的orderID属性的值,后面的order0,order1,orderX 是每个L0接点的子节点的orderID属性的值
这个xsl文件改怎么写?