我是 XML 和 XSLT 的新手,我有一个输入文档,我想在其中提取前缀为 p 、 T 和 C 的元素,并计算带有根 SKU 和列表的序列号。我尝试了很多方法,但无法让它工作,需要一些帮助/建议。
- 在我的 XSLT 中,我将所有带有 safix ppp 的元素复制到输出文件中。
- 在我的 XSLT 中,我将所有带有 safix c00 的元素复制到输出文件中。
- 在我的 XSLT 中,我将所有带有 saefix t0 的元素复制到输出文件中。
很感谢任何形式的帮助。
谢谢您,期待您的回复。
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<product.name>iPhoneX</product.name>
<category>phone</category>
<serial>P0001</serial>
</row>
<row>
<product.name>iPadMini</product.name>
<category>tablet</category>
<serial>T0001</serial>
</row>
<row>
<product.name>iPadMini</product.name>
<category>tablet</category>
<serial>T0002</serial>
</row>
<row>
<product.name>iPhoneX</product.name>
<category>phone</category>
<serial>P0002</serial>
</row>
<row>
<product.name>iMacPro</product.name>
<category>computer</category>
<serial>C0001</serial>
</row>
<row>
<product.name>iMacPro</product.name>
<category>computer</category>
<serial>C0002</serial>
</row>
<row>
<product.name>iPhoneX</product.name>
<category>phone</category>
<serial>P0003</serial>
</row>
<row>
<product.name>iPhoneX</product.name>
<category>phone</category>
<serial>P0004</serial>
</row>
<row>
<product.name>iPhoneX</product.name>
<category>phone</category>
<serial>P0005</serial>
</row>
预期的输出格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<Inventory>
<SKU>
<category>phone</category>
<product.name>iPhoneX</product.name>
<product.count>5</product.count>
<list>P0001</list>
<list>P0002</list>
<list>P0003</list>
<list>P0004</list>
<list>P0005</list>
</SKU>
<SKU>
<category>tablet</category>
<product.name>iPadMini</product.name>
<product.count>2</product.count>
<list>T0001</list>
<list>T0002</list>
</SKU>
<SKU>
<category>computer</category>
<product.name>iMacPro</product.name>
<product.count>2</product.count>
<list>C0001</list>
<list>C0002</list>
</SKU>
</Inventory>
我尝试了很多方法,但无法让它工作,需要一些帮助/建议。
很感谢任何形式的帮助。
谢谢您,期待您的回复。
我能做些什么?