-
Notifications
You must be signed in to change notification settings - Fork 0
/
style_sheet_v1.xsl
29 lines (29 loc) · 1.5 KB
/
style_sheet_v1.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- Create Key based on the Code element -->
<xsl:key name="unique-codes" match="//Reservation" use="Person/UsrAddress/Code" />
<xsl:template match="//document">
<!-- Create SalesOrderHeader/SalesOrderHeaderFields/CustomerNumnber elements based on unique Code values -->
<xsl:for-each select="//Reservation[count(. | key('unique-codes', Person/UsrAddress/Code)[1]) = 1]">
<xsl:sort select="Code" />
<xsl:element name="SalesOrderHeader">
<xsl:element name="SalesOrderHeaderFields">
<xsl:element name="CustomerNumber">
<xsl:value-of select="Person/UsrAddress/Code"/>
</xsl:element>
</xsl:element>
<!-- Create ItemFields/_USERFIELD1 elements grouped by unique Code values -->
<xsl:for-each select="key('unique-codes', Person/UsrAddress/Code)">
<xsl:sort select="Code" />
<xsl:element name="ItemFields">
<xsl:element name="_USERFIELD1">
<xsl:value-of select="OrderNumber" />
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>