Final Assessment
Final Assessment
1. Use the xsl:import function in the main stylesheet (main.xslt) to include the
templates from helper.xslt.
2. Write an XSLT to extract and transform data from a complex XML structure
using advanced XPath expressions.
3. Write a GatewayScript that reads the request chunk body using
readAsBuffers(), transforms the payload by adding a timestamp to each
chunk, and then forwards the modified payload to the backend service.
4. Write an XSLT file to process an XML document using both apply-templates
and call-template. The task is to demonstrate how these approaches can be
used to transform hierarchical XML data into a simplified structure.
5. Take the parameters from headers and do the query params backend
calling along with any oAuth security for the API.
Input1:
<library>
<book>
<title>Book A</title>
<author>Author 1</author>
</book>
<book>
<title>Book B</title>
<author>Author 2</author>
</book>
</library>
Response2:
<shippedOrders>
<order id="1001">
<customer>
<name>John Doe</name>
<email>[email protected]</email>
<address>123 Elm Street, Springfield, IL, 62701</address>
</customer>
<items>
<item>
<name>Laptop</name>
<quantity>1</quantity>
<price currency="USD">1200.00</price>
</item>
<item>
<name>Mouse</name>
<quantity>2</quantity>
<price currency="USD">25.00</price>
</item>
</items>
<totalAmount>1250.00</totalAmount>
<totalItems>3</totalItems>
</order>
</shippedOrders>
Request3:
[
{"id": "1001", "item": "Laptop", "quantity": 1, "price": 1200},
{"id": "1002", "item": "Mouse", "quantity": 2, "price": 25},
{"id": "1003", "item": "Keyboard", "quantity": 1, "price": 50}
]
Response3:
[
{"id": "1001", "item": "Laptop", "quantity": 1, "price": 1200, "timestamp": "2024-
12-17T12:34:56.789Z"},
{"id": "1002", "item": "Mouse", "quantity": 2, "price": 25, "timestamp": "2024-
12-17T12:34:56.789Z"},
{"id": "1003", "item": "Keyboard", "quantity": 1, "price": 50, "timestamp": "2024-
12-17T12:34:56.789Z"}
]
Request4:
<company>
<department name="Engineering">
<employee id="E001">
<name>John Doe</name>
<role>Software Engineer</role>
<salary>80000</salary>
</employee>
<employee id="E002">
<name>Jane Smith</name>
<role>DevOps Engineer</role>
<salary>85000</salary>
</employee>
</department>
<department name="Marketing">
<employee id="M001">
<name>Emily Brown</name>
<role>Marketing Manager</role>
<salary>90000</salary>
</employee>
<employee id="M002">
<name>Michael Green</name>
<role>Content Specialist</role>
<salary>60000</salary>
</employee>
</department>
</company>
Output4:
<companySummary>
<department name="Engineering">
<employeeDetails>John Doe (Software Engineer)</employeeDetails>
<employeeDetails>Jane Smith (DevOps Engineer)</employeeDetails>
</department>
<department name="Marketing">
<employeeDetails>Emily Brown (Marketing Manager)</employeeDetails>
<employeeDetails>Michael Green (Content Specialist)</employeeDetails>
</department>
</companySummary>