How to do xslt transformation for xml processing-long xml files?

I recently met with xslt transformations. I have a task to do the conversion for the xml file that the data was displayed in tables. An example of a fragment:
test.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>

<root>
 <APPLICATION ID="88deeba4-69b1-454a-992a-fae3cebfbca1" TYPENAME="MTZMetaModel" NAME="Spec:Metamodel" IsLocked="LockPermanent" WorkOffline="False" STATUS="00000000-0000-0000-0000-000000000000" SecureStyleID="00000000-0000-0000-0000-000000000000">
 <MTZAPP_COL IsLocked="0">
 <MTZAPP ID="ff0e4214-a70d-484c-8b80-0ff708b1837c" Deleted="False" IsLocked="0" RetriveTime="636886968601287765" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" Name="Administration" DBName="" TheComment="">
 <ParentPackage_COL IsLocked="0" />
</MTZAPP>
 <MTZAPP ID="a719b764-60a2-4090-bf9b-0ca9501b8da8" Deleted="False" IsLocked="0" RetriveTime="636886968601287765" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" Name="Core" DBName="" TheComment="">
 <ParentPackage_COL IsLocked="0" />
</MTZAPP>
 <MTZAPP ID="0290e99f-62ec-4012-9fed-3589d8fd1590" Deleted="False" IsLocked="0" RetriveTime="636886968601287765" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" Name="BP3" DBName="" TheComment="Environment rapid prototyping V3">
 <ParentPackage_COL IsLocked="0" />
</MTZAPP>
 <MTZAPP ID="46ed2fa7-4f35-4527-91a6-a61cfe1c3905" Deleted="False" IsLocked="0" RetriveTime="636886968601287765" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" Name="iUROK" DBName="" TheComment="">
 <ParentPackage_COL IsLocked="0" />
</MTZAPP>
 <MTZAPP ID="946f9ece-7281-488f-99d0-3a4f64da5c1d" Deleted="False" IsLocked="0" RetriveTime="636886968601287765" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" Name="STD" DBName="" TheComment="">
 <ParentPackage_COL IsLocked="0" />
</MTZAPP>
 <MTZAPP ID="2eb473eb-a886-47ad-abab-4e4b3642dcf2" Deleted="False" IsLocked="0" RetriveTime="636886968601287765" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" Name="Ядро2" DBName="" TheComment="">
 <ParentPackage_COL IsLocked="0" />
</MTZAPP>
</MTZAPP_COL>
...
</APPLICATION>
</root>


style.xsl
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<html>
 <body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
 <h1><xsl:value-of select="root/APPLICATION/@NAME"/> </h1>
 <table border="1">
the <tr>
<td>ID</td>
<td>Deleted</td>
<td>IsLocked</td>
<td>RetriveTime</td>
<td>ChangeTime</td>
<td>AccessTime</td>
<td>SecureStyleID</td>
<td>Name</td>
<td>DBName</td>
<td>TheComment</td>
</tr>
 <xsl:for-each select="root/APPLICATION/MTZAPP_COL/MTZAPP">
the <tr>
 <td><xsl:value-of select="@ID"/></td>
 <td><xsl:value-of select="@Deleted"/></td>
 <td><xsl:value-of select="@IsLocked"/></td>
 <td><xsl:value-of select="@RetriveTime"/></td>
 <td><xsl:value-of select="@ChangeTime"/></td>
 <td><xsl:value-of select="@AccessTime"/></td>
 <td><xsl:value-of select="@SecureStyleID"/></td>
 <td><xsl:value-of select="@Name"/></td>
 <td><xsl:value-of select="@DBName"/></td>
 <td><xsl:value-of select="@TheComment"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>

</xsl:template>
</xsl:stylesheet>


It turned out so :
5c98d44985846575982481.png
In the file test.xml somewhere 7500 rows, the remaining data differ from those shown above look like so:
<OBJECTMODE_COL IsLocked="0">
 <OBJECTMODE ID="67a2da64-1444-4e9f-9c60-89923b4bcc6d" Deleted="False" IsLocked="0" RetriveTime="636886970732723806" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" Name="edit" DefaultMode="0" TheComment="edit">
 <STRUCTRESTRICTION_COL IsLocked="0" />
 <METHODRESTRICTION_COL IsLocked="0" />
 <FIELDRESTRICTION_COL IsLocked="0" />
</OBJECTMODE>
 <OBJECTMODE ID="96c54a86-ef5e-4168-b26d-b9858dacf7b6" Deleted="False" IsLocked="0" RetriveTime="636886970732723806" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" Name="read" DefaultMode="-1" TheComment=read-only"main">
 <STRUCTRESTRICTION_COL IsLocked="0">
 <STRUCTRESTRICTION ID="07195bc3-703a-4e10-9d6c-bbcd5c031834" Deleted="False" IsLocked="0" RetriveTime="636886970732983101" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" Struct="4a5cf015-c18d-4149-b965-806ff5beb13a" AllowRead="-1" AllowAdd="0" AllowEdit="-1" AllowDelete="0" />
</STRUCTRESTRICTION_COL>
 <METHODRESTRICTION_COL IsLocked="0" />
 <FIELDRESTRICTION_COL IsLocked="0">
 <FIELDRESTRICTION ID="1d371bad-9e08-405e-94f1-30d22f0a20e3" Deleted="False" IsLocked="0" RetriveTime="636886970733032974" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" ThePart="4a5cf015-c18d-4149-b965-806ff5beb13a" TheField="91fb40df-4f94-4ede-b63d-040ab311b8b2" AllowRead="-1" AllowModify="0" MandatoryField="0" />
 <FIELDRESTRICTION ID="aa91eac0-fa3a-413b-9a91-47d5cc72d68f" Deleted="False" IsLocked="0" RetriveTime="636886970733032974" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" ThePart="4a5cf015-c18d-4149-b965-806ff5beb13a" TheField="0dcf3edc-c76e-4e6f-842a-59093fa7c48e" AllowRead="-1" AllowModify="0" MandatoryField="0" />
 <FIELDRESTRICTION ID="b5d3b2e6-dc7d-40ec-9428-d727a56c541e" Deleted="False" IsLocked="0" RetriveTime="636886970733032974" ChangeTime="599264352000000000" AccessTime="599264352000000000" SecureStyleID="00000000-0000-0000-0000-000000000000" ThePart="4a5cf015-c18d-4149-b965-806ff5beb13a" TheField="f98c660f-53f3-42f2-af1b-0f70e0ec5a70" AllowRead="-1" AllowModify="0" MandatoryField="0" />
</FIELDRESTRICTION_COL>
 </OBJECTMODE>


Need for all elements separately to create the tables in style.xsl or is there some easier way ?
March 19th 20 at 08:29
1 answer
March 19th 20 at 08:31
If different structure element, you'll have to handle separately.
If there are similarities, it is possible together. List them in apply-templates and select a template match.

XML
https://pastebin.com/DeN4rRnY

XSLt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template match="/root/APPLICATION">
<html>
 <body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
 <h1><xsl:value-of select="root/APPLICATION/@NAME"/> </h1>
 <table border="1">
the <tr>
<td>ID</td>
<td>Deleted</td>
<td>IsLocked</td>
<td>RetriveTime</td>
<td>ChangeTime</td>
<td>AccessTime</td>
<td>SecureStyleID</td>
<td>Name</td>
<td>DBName</td>
<td>TheComment</td>
</tr>
 <xsl:apply-templates select="MTZAPP_COL/MTZAPP | OBJECTMODE_COL/OBJECTMODE"/>
</table>
</body>
</html>
</xsl:template>

 <xsl:template match="MTZAPP_COL/MTZAPP | OBJECTMODE_COL/OBJECTMODE">
the <tr>
 <td><xsl:value-of select="@ID"/></td>
 <td><xsl:value-of select="@Deleted"/></td>
 <td><xsl:value-of select="@IsLocked"/></td>
 <td><xsl:value-of select="@RetriveTime"/></td>
 <td><xsl:value-of select="@ChangeTime"/></td>
 <td><xsl:value-of select="@AccessTime"/></td>
 <td><xsl:value-of select="@SecureStyleID"/></td>
 <td><xsl:value-of select="@Name"/></td>
 <td><xsl:value-of select="@DBName"/></td>
 <td><xsl:value-of select="@TheComment"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>


Result
https://pastebin.com/PizDCL0M

PS cycles in XSLt is not good. Those I want to say that you need to avoid cycles in favor of apply templates wherever possible. They complicate the table, make it impossible for re use and generally contrary to the ideology of the tool

Find more questions by tags XMLXSL & XSLT