Need help XSLT

Here should go questions about transforming XML with XSLT and FOP.
dmm6ra
Posts: 1
Joined: Tue Nov 09, 2021 2:38 pm

Need help XSLT

Post by dmm6ra »

Hello,

I have never worked in XSLT before and have a small need to generate a new xml based on an input xml file. Can someone help me here to create a basic xslt and i can take it from there and learn and adapt it to my requirement?

my input xml is something like this

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<TestCode version="10.0">
	<TestCategory name="SmokeTest">
		<Test name="CheckType_123"  type="String">
			<Test_description>No description available for this Test</Test_description>
			<context name="Testing">
				<value>ABC</value>
				<value>XYZ</value>
			</context>
		</Test>
		<Test name="CheckType_PQR"  type="String">
			<Test_description>No description available for this Test</Test_description>
			<context name="SmokeTest">
				<value>ABC</value>
			</context>
		</Test>
		<Test name="ValueAdded_123"  type="String">
			<Test_description>No description available for this Test</Test_description>
			<context name="Testing">
				<value>ABC</value>
				<value>XYZ</value>
			</context>
		</Test>
	</TestCategory>
</TestCode>
From the above xml file, I need to check if i have tag

Code: Select all

<Test name=CheckType_*
and if yes, i need to check if i have

Code: Select all

context/vlaue = XYZ
. If exist i need to take the whole

Code: Select all

<Test ...> </Test>
tag and put it in a new xml file.

So from the above xml, the output what i need is:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<TestCode version="10.0">
	<TestCategory name="SmokeTest">
		<Test name="CheckType_123"  type="String">
			<Test_description>No description available for this Test</Test_description>
			<context name="Testing">
				<value>ABC</value>
				<value>XYZ</value>
			</context>
		</Test>
	</TestCategory>
</TestCode>
because from my input xml, the second Test tag has no value XYZ and 3rd Test tag has no name starting with CheckType_*. Can you help me with this?