Convert data to column data with XMLXSLT

zhaozj2021-02-16  46

Abstract For a long time, how to convert a line of data has always been a very common problem. This article describes how to convert XML with XSL. XML data is taken from row data of the database, and then use the XSL conversion output as column data.

In the example, the groupID element is used as row data, and the transformed column data is indicated by tradeID.

Use XSL: Key to generate a unique key for each GroupID.

Variable 1stGroupId is the entrance of all substro of GroupID. Use to get column values.

Each GroupID calls the showtradesingroup template.

In the ShowTradesingRoup template, loop get all the subtots of GroupID.

XML data (record record in the database table): 244133l 244133L_EUR_STUB < GroupID> 325866L 325866L_EUR_STUB 244133L 325867L_EUR_STUB1 502722L < / GroupID> 502722L_EUR_STUB 244133L 325867L_EUR_STUB2 502722L < Tradeid> 502722l_eur_stub1 502722l 502722l_eur_stub2

XSLT code:

< XSL: Variable name = "1stgroupID">

,

The result is: 244133L, 244133L_EUR_STUB, 325867L_EUR_STUB1, 325867L_EUR_STUB2325866L, 325866L_EUR_STUB5027222L, 502722L_EUR_STUB, 502722L_EUR_STUB1, 502722L_EUR_STUB2

转载请注明原文地址:https://www.9cbs.com/read-27860.html

New Post(0)