XSLT将xml中的多个相同节点处理成一行

时间:2017-05-12 06:48:34

标签: xml xslt xsl-fo

我是Xslt的新手,我想处理具有两个相同节点但只有一个不同属性的XML。在不同的属性输出的基础上,应该在同一行上有两个不同的列。 如果数据集ID以8位数字开头,则应进入“数据集ID 1”列和如果以10位数字开头,则应转到“数据集标识2”列 这是XML -

<?xml version="1.0" encoding="ISO-8859-1"?>

    <DisplayDefinitionTable>
        <columns>
            <column_entry order_num="1">Name</column_entry>
            <column_entry order_num="2">Id</column_entry>
            <column_entry order_num="3">DatasetID</column_entry>
        </columns>
        <rows>
            <row>
                <object_tag tag="45106" uid="yfVhkbLv6Vq5bD"/>
                <object_tag tag="45922" uid="BebdkpIm6Vq5bD"/>
                <row_element column="1" component_tag="45925" property_name="name">DEM</row_element>
                <row_element column="2" component_tag="45925" property_name="Id">8888431618</row_element>
                <row_element column="3" component_tag="50853" property_name="DatasetID">31661449AA</row_element>

            </row>
            <row>
                <object_tag tag="45106" uid="yfVhkbLv6Vq5bD"/>
                <object_tag tag="45922" uid="BebdkpIm6Vq5bD"/>
                <row_element column="1" component_tag="45925" property_name="name">DEM</row_element>
                <row_element column="2" component_tag="45925" property_name="Id">8888431618</row_element>
                <row_element column="3" component_tag="50854" property_name="DatasetID">8888431618A</row_element>

            </row>
            <row>
                <object_tag tag="45175" uid="HReh0zDS6Vq5bD"/>
                <object_tag tag="45922" uid="BebdkpIm6Vq5bD"/>  
                <row_element column="1" component_tag="51997" property_name="name">CEM</row_element>
                <row_element column="2" component_tag="51997" property_name="Id">8888516207</row_element>
                <row_element column="3" component_tag="52010" property_name="DatasetID">8888516207/C</row_element>

            </row>
            <row>
                <object_tag tag="45175" uid="HReh0zDS6Vq5bD"/>
                <object_tag tag="45922" uid="BebdkpIm6Vq5bD"/>

                <row_element column="1" component_tag="51997" property_name="name">CEM</row_element>
                <row_element column="2" component_tag="51997" property_name="Id">8888516207</row_element>
                <row_element column="3" component_tag="52011" property_name="DatasetID">31661809AB</row_element>

            </row>
            <row>
                <object_tag tag="44593" uid="07Uh0rzi6Vq5bD"/>
                <object_tag tag="45922" uid="BebdkpIm6Vq5bD"/>
                <row_element column="1" component_tag="52019" property_name="name">TT</row_element>
                <row_element column="2" component_tag="52019" property_name="Id">8888574081</row_element>
                <row_element column="3" component_tag="52992" property_name="DatasetID">8888574081/C</row_element>

            </row>
            <row>
                <object_tag tag="44593" uid="07Uh0rzi6Vq5bD"/>
                <object_tag tag="45922" uid="BebdkpIm6Vq5bD"/>
                <row_element column="1" component_tag="52019" property_name="name">TT</row_element>
                <row_element column="2" component_tag="52019" property_name="Id">8888574081</row_element>
                <row_element column="3" component_tag="52993" property_name="DatasetID">31691071/AC</row_element>

            </row>
        </DisplayDefinitionTable>

我期待像

这样的输出
Name    ID  DatasetId1  DatasetId2
DEM 8888431618  31661449AA  8888431618A
CEM 8888516207  31661809AB  8888516207/C

0 个答案:

没有答案