Вот мой xml
<?xml version='1.0' encoding='UTF-8'?>
<Report_Data>
<Report_Entry>
<PERSON>12345</PERSON>
<NAME> Person Name </NAME>
<Emergency_Contacts_group>
<ADDRESS_LINE_1>Emergency contact address 1</ADDRESS_LINE_1>
<ADDRESS_LINE_2>Emergency contact address 2</ADDRESS_LINE_2>
<ADDRESS_LINE_3>Emergency contact address 3</ADDRESS_LINE_3>
<ADDRESS_LINE_4>Emergency contact address 4</ADDRESS_LINE_4>
</Emergency_Contacts_group>
<Trustee_group>
<TRUST_ADDRESS_LINE_1>TRUSTEE address 1</TRUST_ADDRESS_LINE_1>
<TRUST_ADDRESS_LINE_2>TRUSTEE address 2</TRUST_ADDRESS_LINE_2>
<TRUST_ADDRESS_LINE_3>TRUSTEE address 3</TRUST_ADDRESS_LINE_3>
</Trustee_group>
</Report_Entry>
</Report_Data>
Требуется получить вывод в следующем формате:
PERSON|NAME|ADDRESS_LINE_TYPE|ADDRESS_LINE_DATA|TRUSTEE_ADDRESS_LINE_TYPE|TRUSTEE_ADDRESS_DATA
12345|Person Name|ADDRESS_LINE_1|Emergency contact address 1|ADDRESS_LINE_1|TRUSTEE address 1
12345|Person Name|ADDRESS_LINE_2|Emergency contact address 2|ADDRESS_LINE_2|TRUSTEE address 2
12345|Person Name|ADDRESS_LINE_3|Emergency contact address 3|ADDRESS_LINE_3|TRUSTEE address 3
12345|Person Name|ADDRESS_LINE_4|Emergency contact address 4||
Я написал XSLT, у него проблема
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>Person|Address_LINE_TYPE| ADDRESS_LINE_DATA</xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*[contains(name(),'ADDRESS_LINE')]">
<xsl:text>
</xsl:text>
<xsl:value-of select="../../PERSON"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="local-name()"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
, который производит вывод, подобный этому, что неправильно:
Person|Address_LINE_TYPE| ADDRESS_LINE_DATA
12345|ADDRESS_LINE_1|Emergency contact address 1
12345|ADDRESS_LINE_2|Emergency contact address 2
12345|ADDRESS_LINE_3|Emergency contact address 3
12345|ADDRESS_LINE_4|Emergency contact address 4
12345|TRUST_ADDRESS_LINE_1|TRUSTEE address 1
12345|TRUST_ADDRESS_LINE_2|TRUSTEE address 2
12345|TRUST_ADDRESS_LINE_3|TRUSTEE address 3
Проблема: 1 Данные Trustee_Group печатаются ниже аварийного контакта.
Проблема: 2 нужен отдельный столбец для типа строки адреса Trustee_group и это должно ADDRESS_LINE_1, а не TRUST_ADDRESS_LINE_1
Пожалуйста, помогите мне достичь желаемого результата.