XSLT: Looping and setting a variable when condition met at least once - variables

I am trying to loop through a node, which in itselt is not a problem. I want to check to see if the selectedLetter matches the first letter of the node, which is working as intended (see code below). The difficulties arise in that I would like to present some alternative text if the conditional "" is not met at least once during the loop, along the lines of "Sorry, no documents begin with that letter". I was thinking about setting a variable i.e. flag in the conditional and check later on if this variable has been set, but from what I have read here, the scope of the variable is restricted and only available within the loop? Can anyone offer any assistance?
Cheers,
Taff
<xsl:param name="selectedLetter" select="''"/>
<xsl:key name="docLetter" match="docs" use="substring(text()),1,1)"/>
<xsl:for-each select="//ad-documents/item">
<xsl:sort select="documentName"/>
<xsl:variable name="firstLetter" select="upper-case(substring(documentName, 1, 1))"/>
<xsl:choose>
<xsl:when test="$firstLetter = $selectedLetter">
<div class="doc-date">
<xsl:if test="upload-date/day < 10">0</xsl:if>
<xsl:value-of select="upload-date/day"/>
<xsl:text>.</xsl:text>
<xsl:if test="upload-date/month < 10">0</xsl:if>
<xsl:value-of select="upload-date/month"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="upload-date/year"/>
</div>
<div class="doc-link">
<a>
<xsl:attribute name="href">
<xsl:choose>
<xsl:when test="isEditableFormDoc/box = 'true'">
#
</xsl:when>
<xsl:otherwise>
<xsl:text>/img/ejbfile/</xsl:text>
<xsl:value-of select="documents/document/#documentName"/>
<xsl:text>?id=</xsl:text>
<xsl:value-of select="documents/document/#src"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:if test="isEditableFormDoc/box = 'true'">
<xsl:attribute name="target">
<xsl:text>_blank</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="documentName"/>
</a>
</div>
<div class="doc-short-desc">
<xsl:apply-templates select="document-short-desc" mode="format"/>
</div>
<!--<xsl:apply-templates select="//ad-documents/item" mode="filteredDocuments"/>-->
</xsl:when>
</xsl:choose>
</xsl:for-each>
EDIT:
XML Example
<ad-documents name="ad-documents" label="Dokumente (limitiert auf 20 pro Seite)">
<item description="Doc%203" id="1" timestamp="1328525592205">
<documentName name="documentName" description="Doc%203">Doc 3</documentName>
<optionalLetter name="optionalLetter" description="c">c</optionalLetter>
<document-short-desc name="document-short-desc" description="">
<p>yxf</p>
</document-short-desc>
<upload-date name="upload-date" description="">
<day>24</day>
<month>2</month>
<year>2012</year>
</upload-date>
<isEditableFormDoc name="isEditableFormDoc" description="">
<box/>
</isEditableFormDoc>
<documents name="documents" description=""/>
</item>
<item description="Doc%204" id="2" timestamp="1328525624889">
<documentName name="documentName" description="Doc%204">Doc 4</documentName>
<optionalLetter name="optionalLetter" description="z%2Ci%2Cg">z,i,g</optionalLetter>
<document-short-desc name="document-short-desc" description="">
<p>asff</p>
</document-short-desc>
<upload-date name="upload-date" description="">
<day>25</day>
<month>2</month>
<year>2012</year>
</upload-date>
<isEditableFormDoc name="isEditableFormDoc" description="">
<box/>
</isEditableFormDoc>
<documents name="documents" description=""/>
</item>
<item description="Doc%201" id="1" timestamp="1328523551639">
<documentName name="documentName" description="Doc%201">Doc 1</documentName>
<optionalLetter name="optionalLetter" description="b%2Cc">b,c</optionalLetter>
<document-short-desc name="document-short-desc" description="">
<p>Short Desc 1</p>
</document-short-desc>
<upload-date name="upload-date" description="">
<day>9</day>
<month>2</month>
<year>2012</year>
</upload-date>
<isEditableFormDoc name="isEditableFormDoc" description="">
<box/>
</isEditableFormDoc>
<documents name="documents" description=""/>
</item>
</ad-documents>

The solution is simple:
Just replace:
<xsl:for-each select="//ad-documents/item">
with
<xsl:for-each select=
"//ad-documents/item
[$selectedLetter eq upper-case(substring(documentName, 1, 1) ]">
You can add after this xsl:for-each
<xsl:sequence select=
"'YourErrorMessage'
[not(//ad-documents/item
[$selectedLetter eq upper-case(substring(documentName, 1, 1) ]
)
]"
/>

Thanks to Dimitre, I managed to solve the problem with count()
<xsl:variable name="foundDocs" select="count(//ad-documents/item[$selectedLetter eq upper-case(substring(documentName, 1, 1))])"/>
<xsl:if test="$foundDocs = 0">
<div class="no-documents">
<xsl:text>Leider keine Dokumente gefunden</xsl:text>
</div>
</xsl:if>

Related

Set an xslt variable with an email

In a BizTalk mapper, I had to set a default e-mail in output field when a specific input field is null or empty.
So I set an XSLT variable with the email but when the condition is good no node is created in the output.
Here is my code:
<xsl:template name="GetEmail">
<xsl:param name="number" />
<xsl:param name="Email" />
<xsl:variable name="defaultmail">noreply#domain.fr</xsl:variable>
<xsl:for-each select="//*[local-name()='Employee']">
<xsl:choose>
<xsl:when test="*[local-name()='Username' and text() = $number] and $Email != ''">
<xsl:element name="email">
<xsl:value-of select="string(*[local-name()='Email'])" />
</xsl:element>
</xsl:when>
<xsl:when test="*[local-name()='Username' and text() = $number] and $Email = ''">
<xsl:element name="email">
<xsl:value-of select="$defaultmail" />
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
Here is my Input file:
<ns0:Root xmlns:ns0="http://schemas.microsoft.com/BizTalk/2003/aggschema">
<InputMessagePart_0>
<Get>
<Employee>
<Username>008441</Username>
<Email />
</Employee>
<Employee>
<Username>014095</Username>
<Email>email2#domain.fr</Email>
</Employee>
<Employee>
<Username>011812</Username>
<Email>email3#domain.fr</Email>
</Employee>
</Get>
</InputMessagePart_0>
<InputMessagePart_1>
<ns1:EmployeeResponse xmlns:ns1="http://Employee">
<ns1:Header />
<ns1:Return>
<ns1:Employee>
<ns1:Number>008441</ns1:Number>
</ns1:Employee>
</ns1:Return>
</ns1:EmployeeResponse>
</InputMessagePart_1>
</ns0:Root>
And here is the output:
<Employee>
<username>123456789</username>
<firstname>Firstname</firstname>
<lastname>Lastname</lastname>
<birthdate>dd/MM/yyyy</birthdate>
<email />
</Employee>
And what it should be:
<Employee>
<username>123456789</username>
<firstname>Firstname</firstname>
<lastname>Lastname</lastname>
<email>noreply#domain.fr</email>
<birthdate>dd/MM/yyyy</birthdate>
</Employee>
I have 2 input files, one is provided by my customer and the other is provided by our DB.
The first file from customer contains a list of employees.
The second file from our DB contains only one employee identified with the Username in the first file. There is a loop so for each employee in the first file we get the employee datas related to Username. We need two datas in our DB related to each employee to calculate 2 fields in output file.
The output must contains all datas from the first one and the 2 calculated fields.
If the email field is not provided (empty or null) in the first file (from my customer), BizTalk mapper take the email of the next employee with an non empty email field.
So in my example, the output will be:
<Employee>
<username>008441</username>
<firstname>Firstname</firstname>
<lastname>Lastname</lastname>
<email>email2#domain.fr</email>
<birthdate>dd/MM/yyyy</birthdate>
</Employee>
instead of :
<Employee>
<username>008441</username>
<firstname>Firstname</firstname>
<lastname>Lastname</lastname>
<email>noreply#domain.fr</email>
<birthdate>dd/MM/yyyy</birthdate>
</Employee>
You should NOT try to link from both InputMessagePart_0 and InputMessagePart_1, that just confuses the looping, and you are already creating the loop inside the XSLT for InputMessagePart_0 with your for-each-select. Just link the Number from InputMessagePart_1 and use the following XSLT. Also select the Email from the node, and not pass it in as a variable.
<xsl:template name="GetEmail">
<xsl:param name="number" />
<xsl:variable name="defaultmail">noreply#domain.fr</xsl:variable>
<xsl:for-each select="//*[local-name()='Employee']">
<xsl:choose>
<xsl:when test="*[local-name()='Username' and text() = $number]">
<xsl:choose>
<xsl:when test="*[local-name()='Email' and text() != '']">
<xsl:element name="email">
<xsl:value-of select="string(*[local-name()='Email'])" />
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="email">
<xsl:value-of select="$defaultmail" />
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
change your code to:
<xsl:template name="GetEmail">
<xsl:param name="number" />
<xsl:param name="Email" />
<xsl:variable name="defaultmail">
<xsl:value-of select='noreply#domain.fr'/>
</xsl:variable>
<xsl:for-each select="//*[local-name()='Employee']">
<xsl:choose>
<xsl:when test="[local-name()='Username' and text() = $number] and string-length($Email) >0">
<xsl:element name="email">
<xsl:value-of select="string(*[local-name()='Email'])" />
</xsl:element>
</xsl:when>
<xsl:when test="*[local-name()='Username' and text() = $number] and string-length($Email) &eq;0">
<xsl:element name="email">
<xsl:value-of select="$defaultmail" />
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>

Dynamically specifying a document into a variable using XSLT1

I have seen the answers here but they are not working.
I can use either of the following:
<xsl:variable name="AssignHistory" select="document('AssignHistory.xml')"/>
<xsl:variable name="AssignHistory" select="document('ForeignAssignHistory.xml')"/>
But I need to make this dynamic now. So I tried this but it doesn't like it:
<xsl:variable name="AssignHistory">
<xsl:choose>
<xsl:when test="//Settings/ForeignGroupMode=1">
<xsl:value-of select="document('ForeignAssignHistory.xml')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="document('AssignHistory.xml')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
It just won't work. It says:
Reference to variable or parameter 'AssignHistory' must evaluate to a node list.
To give this some context. This is what I have at the moment:
<td class="cellComments" colspan="4">
<xsl:variable name="AssignHistory" select="document('AssignHistory.xml')"/>
<xsl:variable name="week" select="Date/#NextWeek"/>
<xsl:variable name="NextReviewQuestion" select="$AssignHistory/AssignmentHistory/*[name()=$week]/ReviewQuestion"/>
<xsl:if test="normalize-space($NextReviewQuestion) != ''">
<xsl:if test="normalize-space(ReviewQuestion) != ''">
<span class="textReviewQuestionLabel">
<xsl:value-of select="//Labels/NextReviewQuestion"/> 
</span>
<span class="textReviewQuestion">
<xsl:value-of select="$NextReviewQuestion"/>
</span>
<br />
</xsl:if>
</xsl:if>
<br />
<br />
<br />
</td>
And I wanted to introduce that selection logic to choose the correct document.
Perhaps try something like:
<xsl:variable name="AssignHistoryPath">
<xsl:choose>
<xsl:when test="//Settings/ForeignGroupMode=1">ForeignAssignHistory.xml</xsl:when>
<xsl:otherwise>AssignHistory.xml</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="AssignHistory" select="document($AssignHistoryPath)"/>
Untested, because because no code to test with was provided.

How to fix 'Errors were reported during stylesheet compilation' in XSLT?

I have this SaxonApiException when I run my XSLT code on https://xslttest.appspot.com/. It return this error :
net.sf.saxon.s9api.SaxonApiException: Errors were reported during stylesheet compilation
I tried on another online tester https://www.freeformatter.com/xsl-transformer.html but I got the same error.
I tried to split my XSLT code. First part with the process of extract ZipCode in Wages and second part with the process of extract ZipCode in Addresses.
Both works when they're separated so I think I made a mistake in the 'choose' element but cannot find it.
Here is my XSLT code...
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/EmployeeUDM_Response/Return/Employee">
<xsl:for-each select="./Wages/Wage">
<xsl:choose>
<xsl:when test="DissimelarZipCode != ''">
<xsl:value-of select="DissimelarZipCode" />
</xsl:when>
<otherwise>
<xsl:for-each select="./Addresses/Address" />
<!-- year -->
<xsl:sort select="substring(StartDate, 1, 4)" order="descending" data-type="number"/>
<!-- month -->
<xsl:sort select="substring(StartDate, 6, 2)" order="descending" data-type="number"/>
<!-- day -->
<xsl:sort select="substring(StartDate, 9, 2)" order="descending" data-type="number"/>
<xsl:if test="position() = 1">
<xsl:value-of select="./ZipCode" />
</xsl:if>
</otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
...and my XML file
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl"?>
<EmployeeUDM_Response xmlns:ns0="http://ESB/Schemas/v2/EmployeeUDM">
<Header Type="Employee" Source="Biztalk ESB" />
<Return>
<Employee>
<Wages>
<Wage>
<StartDate>2019-04-22T00:00:00.0000000+02:00</StartDate>
<EndDate>2019-05-01T00:00:00.0000000+02:00</EndDate>
<DissimelarZipCode>5430 NU</DissimelarZipCode>
</Wage>
</Wages>
<Addresses>
<Address>
<StartDate>2014-01-01T00:00:00.0000000+02:00</StartDate>
<EndDate></EndDate>
<ZipCode>6099 EB</ZipCode>
</Address>
<Address>
<StartDate>2015-01-01T00:00:00.0000000+02:00</StartDate>
<EndDate></EndDate>
<ZipCode>5487 YR</ZipCode>
</Address>
</Addresses>
</Employee>
</Return>
</EmployeeUDM_Response>
I expected the output of the ZipCode in Wage (5430 NU in this case) or, if ZipCode in Wage is empty, the ZipCode in Address with the latest StartDate (5487 YR in this case)
1. There should be <xsl:otherwise> instead of <otherwise>
2. <xsl:sort> should be in <xsl:for-each> .(You have ended the loop in same line)
3. To loop over Address, you will need xpath ../../Addresses/Address. Because at that time <Wage> is being processed. ( ../ will bring you up one level to parent node.)
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/EmployeeUDM_Response/Return/Employee">
<xsl:for-each select="Wages/Wage">
<xsl:choose>
<xsl:when test="DissimelarZipCode != ''">
<xsl:value-of select="DissimelarZipCode" />
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="../../Addresses/Address">
<!-- year -->
<xsl:sort select="substring(StartDate, 1, 4)" order="descending"
data-type="number" />
<!-- month -->
<xsl:sort select="substring(StartDate, 6, 2)" order="descending"
data-type="number" />
<!-- day -->
<xsl:sort select="substring(StartDate, 9, 2)" order="descending"
data-type="number" />
<xsl:if test="position() = 1">
<xsl:value-of select="ZipCode" />
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
https://xsltfiddle.liberty-development.net/pPzifpP

How can I eliminate a duplicate result in XSLT 1.0?

I am using the Altova mapping tool and I cannot find an option on how to eliminate a duplicate value so I am trying to update the XSLT file directly and I cannot figure out how to do this. Below is the XSLT file, the problem is in the Detail06 section.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <xsl:template match="/">
<AsyncBarcode>
<xsl:variable name="var1_instance" select="." />
<xsl:for-each select="$var1_instance/n:SyncReceiveDelivery">
<xsl:variable name="var2_SyncReceiveDelivery" select="." />
<Prefix>
<xsl:for-each select="n:DataArea/n:Sync/n:AccountingEntityID">
<CompanyID>
<xsl:value-of select="string(.)" />
</CompanyID>
</xsl:for-each>
<xsl:for-each select="n:DataArea/n:Sync/n:AccountingEntityID">
<ExternalPartnerID>
<xsl:value-of select="string(.)" />
</ExternalPartnerID>
</xsl:for-each>
<DocumentType>
<xsl:value-of select="'AsyncBarcode'" />
</DocumentType>
<xsl:for-each select="n:ApplicationArea/n:BODID">
<DocumentNumber>
<xsl:value-of select="substring-after(substring-before(string(.), ':1?'), 'Infor:')" />
</DocumentNumber>
</xsl:for-each>
<TransactionDirection>
<xsl:value-of select="'I'" />
</TransactionDirection>
<DateStamp>
<xsl:value-of select="substring-before(string(n:ApplicationArea/n:CreationDateTime), 'T')" />
</DateStamp>
<TimeStamp>
<xsl:value-of select="substring-before(substring-after(string(n:ApplicationArea/n:CreationDateTime), 'T'), 'Z')" />
</TimeStamp>
<xsl:for-each select="n:ApplicationArea/n:BODID">
<ControlNumber>
<xsl:value-of select="substring-after(substring-before(string(.), ':1?'), 'Infor:')" />
</ControlNumber>
</xsl:for-each>
</Prefix>
<Header00>
<TransactionDefinitionKey>
<xsl:value-of select="'25'" />
</TransactionDefinitionKey>
<xsl:for-each select="n:DataArea/n:Sync/n:AccountingEntityID">
<CompanyID0>
<xsl:value-of select="string(.)" />
</CompanyID0>
</xsl:for-each>
<xsl:for-each select="n:DataArea/n:ReceiveDelivery/n:ReceiveDeliveryHeader/n:DocumentReference/n:DocumentID">
<xsl:variable name="var14_DocumentID" select="." />
<xsl:if test="$var14_DocumentID/n:ID/#location">
<BranchID>
<xsl:value-of select="substring-before(string(n:ID/#location), '-B')" />
</BranchID>
</xsl:if>
</xsl:for-each>
<UserID>
<xsl:value-of select="'WMUser'" />
</UserID>
<xsl:for-each select="n:DataArea/n:ReceiveDelivery/n:ReceiveDeliveryHeader/n:WarehouseLocation/n:ID">
<WarehouseID>
<xsl:value-of select="substring-before(string(.), '-W')" />
</WarehouseID>
</xsl:for-each>
</Header00>
<xsl:for-each select="n:DataArea/n:ReceiveDelivery/n:ReceiveDeliveryItem">
<Detail01>
<xsl:for-each select="$var2_SyncReceiveDelivery/n:DataArea/n:Sync/n:AccountingEntityID">
<Scanneddata1>
<xsl:value-of select="string(.)" />
</Scanneddata1>
</xsl:for-each>
</Detail01>
</xsl:for-each>
<xsl:for-each select="n:DataArea/n:ReceiveDelivery">
<xsl:variable name="var22_ReceiveDelivery" select="." />
<xsl:for-each select="n:ReceiveDeliveryItem">
<Detail02>
<xsl:for-each select="$var22_ReceiveDelivery/n:ReceiveDeliveryHeader/n:DocumentReference/n:DocumentID">
<xsl:variable name="var26_DocumentID" select="." />
<xsl:if test="$var26_DocumentID/n:ID/#location">
<Scanneddata2>
<xsl:value-of select="substring-before(string(n:ID/#location), '-B')" />
</Scanneddata2>
</xsl:if>
</xsl:for-each>
</Detail02>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="n:DataArea/n:ReceiveDelivery">
<xsl:variable name="var28_ReceiveDelivery" select="." />
<xsl:for-each select="n:ReceiveDeliveryItem">
<Detail03>
<xsl:for-each select="$var28_ReceiveDelivery/n:ReceiveDeliveryHeader/n:DocumentReference/n:DocumentID">
<Scanneddata3>
<xsl:value-of select="string(n:ID)" />
</Scanneddata3>
</xsl:for-each>
</Detail03>
</xsl:for-each>
</xsl:for-each>
<xsl:for-each select="n:DataArea/n:ReceiveDelivery/n:ReceiveDeliveryItem">
<Detail04>
<xsl:for-each select="n:LineNumber">
<Scanneddata4>
<xsl:value-of select="string(.)" />
</Scanneddata4>
</xsl:for-each>
</Detail04>
</xsl:for-each>
<xsl:for-each select="n:DataArea/n:ReceiveDelivery/n:ReceiveDeliveryItem">
<xsl:variable name="var38_ReceiveDeliveryItem" select="." />
<Detail05>
<xsl:variable name="var40_map_select_SerializedLot">
<xsl:if test="string((n:SerializedLot/n:Lot/n:LotIDs/n:ID) = (n:SerializedLot/n:Lot/n:LotIDs/n:ID)) != 'false'">
<xsl:value-of select="'1'" />
</xsl:if>
</xsl:variable>
<xsl:variable name="var48_">
<xsl:choose>
<xsl:when test="string(boolean(string($var40_map_select_SerializedLot))) != 'false'">
<xsl:variable name="var45_map_select_SerializedLot">
<xsl:for-each select="n:SerializedLot/n:Lot/n:LotIDs/n:ID">
<xsl:value-of select="string(.)" />
</xsl:for-each>
</xsl:variable>
<xsl:variable name="var41_map_select_SerializedLot">
<xsl:if test="string((string($var45_map_select_SerializedLot)) = (string($var45_map_select_SerializedLot))) != 'false'">
<xsl:value-of select="'1'" />
</xsl:if>
</xsl:variable>
<xsl:if test="string(boolean(string($var41_map_select_SerializedLot))) != 'false'">
<xsl:variable name="var42_map_select_SerializedLot">
<xsl:for-each select="n:SerializedLot/n:Lot/n:LotIDs/n:ID">
<xsl:value-of select="string(.)" />
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="string($var42_map_select_SerializedLot)" />
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="' '" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<Scanneddata5>
<xsl:copy-of select="$var48_" />
</Scanneddata5>
</Detail05>
</xsl:for-each>
<xsl:for-each select="n:DataArea/n:ReceiveDelivery/n:ReceiveDeliveryItem">
<Detail06>
<xsl:for-each select="n:HoldCodes/n:Code">
<Scanneddata6>
<xsl:choose>
<xsl:when test="string((' ' != string(.))) != 'false'">
<xsl:value-of select="'Hold'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'Inventory'" />
</xsl:otherwise>
</xsl:choose>
</Scanneddata6>
</xsl:for-each>
</Detail06>
</xsl:for-each>
<Detail07>
<xsl:for-each select="n:DataArea/n:ReceiveDelivery/n:ReceiveDeliveryHeader/n:ReceivedDateTime">
<Scanneddata7>
<xsl:value-of select="string(.)" />
</Scanneddata7>
</xsl:for-each>
</Detail07>
<xsl:for-each select="n:DataArea/n:ReceiveDelivery/n:ReceiveDeliveryItem">
<Detail11>
<xsl:for-each select="n:ReceivedQuantity">
<Scanneddata11>
<xsl:value-of select="number(string(.))" />
</Scanneddata11>
</xsl:for-each>
</Detail11>
</xsl:for-each>
</xsl:for-each>
</AsyncBarcode>
</xsl:template>
</xsl:stylesheet>
Below is the input I am receiving:
<SyncReceiveDelivery xmlns="http://schema.infor.com/InforOAGIS/2" releaseID="9.2" versionID="2.8.0">
<ApplicationArea>
<Sender>
<LogicalID>lid://</LogicalID>
<ComponentID>Warehouse Management</ComponentID>
<ReferenceID accountingEntity="01" location="RS01-W">0000058141</ReferenceID>
</Sender>
<CreationDateTime>2015-03-31T20:08:16Z</CreationDateTime>
<BODID>infor-nid:infor:01:RS01-W:0000002445:62883?ReceiveDelivery&verb=Sync</BODID>
</ApplicationArea>
<DataArea>
<Sync>
<TenantID>infor</TenantID>
<AccountingEntityID>01</AccountingEntityID>
<LocationID accountingEntity="01">RS01-W</LocationID>
<ActionCriteria>
<ActionExpression actionCode="Add" />
</ActionCriteria>
</Sync>
<ReceiveDelivery>
<ReceiveDeliveryHeader>
<DocumentID>
<ID accountingEntity="01" location="RS01-W" variationID="62883">0000002445</ID>
</DocumentID>
<LastModificationDateTime>2015-03-31T20:08:12Z</LastModificationDateTime>
<DocumentDateTime>2015-03-31T20:08:12Z</DocumentDateTime>
<DocumentReference type="CustomerReturn">
<DocumentID>
<ID accountingEntity="01" location="1323-B">930131</ID>
</DocumentID>
</DocumentReference>
<Status>
<Code listID="ReceiveDeliveryStatus">Received</Code>
</Status>
<WarehouseLocation>
<ID accountingEntity="01">RS01-W</ID>
<Name languageID="en-US">Power Packaging</Name>
<Address>
<AddressLine sequence="1">401 N. Main</AddressLine>
<CityName>Rosendale</CityName>
<CountrySubDivisionCode>WI</CountrySubDivisionCode>
<PostalCode listID="PostalCode">54974</PostalCode>
</Address>
</WarehouseLocation>
<ActualDeliveryDateTime>2015-03-31T17:31:46Z</ActualDeliveryDateTime>
<GrossWeightMeasure unitCode="LB">8120.4147</GrossWeightMeasure>
<TotalVolumeMeasure unitCode="CF">0</TotalVolumeMeasure>
<ShipFromParty>
<Location>
<ID>30155</ID>
<Name languageID="en-US">RS-IFP-USFS HOUSTON</Name>
<Address>
<AddressLine sequence="1">USFS HOUSTON</AddressLine>
<AddressLine sequence="2">111 ALIANT DRIVE</AddressLine>
<CityName>HOUSTON</CityName>
<CountrySubDivisionCode>TX</CountrySubDivisionCode>
<CountryCode>USA</CountryCode>
<PostalCode listID="PostalCode">77032</PostalCode>
</Address>
</Location>
</ShipFromParty>
<ReceivedDateTime>2015-03-31T20:08:12Z</ReceivedDateTime>
<DeliverToParty>
<Location>
<ID accountingEntity="01">RS01-W</ID>
<Name languageID="en-US">Power Packaging</Name>
<Address>
<AddressLine sequence="1">401 N. Main</AddressLine>
<CityName>Rosendale</CityName>
<CountrySubDivisionCode>WI</CountrySubDivisionCode>
<PostalCode listID="PostalCode">54974</PostalCode>
</Address>
</Location>
</DeliverToParty>
<ASNReference>
<DocumentID>
<ID accountingEntity="01" location="RS01-W">0000002445</ID>
</DocumentID>
</ASNReference>
</ReceiveDeliveryHeader>
<ReceiveDeliveryItem>
<ItemID>
<ID accountingEntity="01">200135-100250</ID>
</ItemID>
<ServiceIndicator>false</ServiceIndicator>
<Description languageID="en-US">Orchard Splash 12/25 fl oz Orange Gold 100</Description>
<Note languageID="en-US">1</Note>
<DocumentReference type="CustomerReturn">
<DocumentID>
<ID accountingEntity="01" location="1323-B">930131</ID>
</DocumentID>
<LineNumber>1</LineNumber>
</DocumentReference>
<PackingSlipQuantity unitCode="CS">0.0</PackingSlipQuantity>
<PackingSlipBaseUOMQuantity unitCode="CS">0.0</PackingSlipBaseUOMQuantity>
<ReceivedQuantity unitCode="CS">90.0</ReceivedQuantity>
<ReceivedBaseUOMQuantity unitCode="CS">90.0</ReceivedBaseUOMQuantity>
<ReturnedQuantity unitCode="CS">0.0</ReturnedQuantity>
<ReturnedBaseUOMQuantity unitCode="CS">0.0</ReturnedBaseUOMQuantity>
<SerializedLot>
<ItemQuantity unitCode="CS">90.0</ItemQuantity>
<ItemBaseUOMQuantity unitCode="CS">90.0</ItemBaseUOMQuantity>
<Lot>
<LotIDs>
<ID>RS1412107</ID>
</LotIDs>
<Quantity unitCode="CS">90.0</Quantity>
<BaseUOMQuantity unitCode="CS">90.0</BaseUOMQuantity>
</Lot>
</SerializedLot>
<LineNumber>1</LineNumber>
<HoldCodes>
<Code listID="Hold Reason Codes">HOLD</Code>
</HoldCodes>
<HoldCodes>
<Code listID="Hold Reason Codes">QCREQ</Code>
</HoldCodes>
<CountSequence>1</CountSequence>
</ReceiveDeliveryItem>
<ReceiveDeliveryItem>
<ItemID>
<ID accountingEntity="01">200135-100252</ID>
</ItemID>
<ServiceIndicator>false</ServiceIndicator>
<Description languageID="en-US">Orchard Hills 12/25 fl oz Orange 100</Description>
<Note languageID="en-US">2</Note>
<DocumentReference type="CustomerReturn">
<DocumentID>
<ID accountingEntity="01" location="1323-B">930131</ID>
</DocumentID>
<LineNumber>2</LineNumber>
</DocumentReference>
<PackingSlipQuantity unitCode="CS">0.0</PackingSlipQuantity>
<PackingSlipBaseUOMQuantity unitCode="CS">0.0</PackingSlipBaseUOMQuantity>
<ReceivedQuantity unitCode="CS">90.0</ReceivedQuantity>
<ReceivedBaseUOMQuantity unitCode="CS">90.0</ReceivedBaseUOMQuantity>
<ReturnedQuantity unitCode="CS">0.0</ReturnedQuantity>
<ReturnedBaseUOMQuantity unitCode="CS">0.0</ReturnedBaseUOMQuantity>
<SerializedLot>
<ItemQuantity unitCode="CS">90.0</ItemQuantity>
<ItemBaseUOMQuantity unitCode="CS">90.0</ItemBaseUOMQuantity>
<Lot>
<LotIDs>
<ID>RS141112</ID>
</LotIDs>
<Quantity unitCode="CS">90.0</Quantity>
<BaseUOMQuantity unitCode="CS">90.0</BaseUOMQuantity>
</Lot>
</SerializedLot>
<LineNumber>2</LineNumber>
<HoldCodes>
<Code listID="Hold Reason Codes">HOLD</Code>
</HoldCodes>
<HoldCodes>
<Code listID="Hold Reason Codes">QCREQ</Code>
</HoldCodes>
<CountSequence>1</CountSequence>
</ReceiveDeliveryItem>
<ReceiveDeliveryItem>
<ItemID>
<ID accountingEntity="01">200135-100252</ID>
</ItemID>
<ServiceIndicator>false</ServiceIndicator>
<Description languageID="en-US">Orchard Hills 12/25 fl oz Orange 100</Description>
<Note languageID="en-US">3</Note>
<DocumentReference type="CustomerReturn">
<DocumentID>
<ID accountingEntity="01" location="1323-B">930131</ID>
</DocumentID>
<LineNumber>3</LineNumber>
</DocumentReference>
<PackingSlipQuantity unitCode="CS">0.0</PackingSlipQuantity>
<PackingSlipBaseUOMQuantity unitCode="CS">0.0</PackingSlipBaseUOMQuantity>
<ReceivedQuantity unitCode="CS">90.0</ReceivedQuantity>
<ReceivedBaseUOMQuantity unitCode="CS">90.0</ReceivedBaseUOMQuantity>
<ReturnedQuantity unitCode="CS">0.0</ReturnedQuantity>
<ReturnedBaseUOMQuantity unitCode="CS">0.0</ReturnedBaseUOMQuantity>
<SerializedLot>
<ItemQuantity unitCode="CS">90.0</ItemQuantity>
<ItemBaseUOMQuantity unitCode="CS">90.0</ItemBaseUOMQuantity>
<Lot>
<LotIDs>
<ID>RS1412030</ID>
</LotIDs>
<Quantity unitCode="CS">90.0</Quantity>
<BaseUOMQuantity unitCode="CS">90.0</BaseUOMQuantity>
</Lot>
</SerializedLot>
<LineNumber>3</LineNumber>
<HoldCodes>
<Code listID="Hold Reason Codes">HOLD</Code>
</HoldCodes>
<HoldCodes>
<Code listID="Hold Reason Codes">QCREQ</Code>
</HoldCodes>
<CountSequence>1</CountSequence>
</ReceiveDeliveryItem>
</ReceiveDelivery>
</DataArea>
</SyncReceiveDelivery>
Finally, this is what I am expecting however I am getting duplicates values in Scannedata6 for the Detail06 section:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE AsyncBarcode SYSTEM "C:/InboundBODS/AsyncBarcode_Inbound.dtd">
<AsyncBarcode>
<Prefix>
<CompanyID>01</CompanyID>
<ExternalPartnerID>01</ExternalPartnerID>
<DocumentType>AsyncBarcode</DocumentType>
<DocumentNumber/>
<TransactionDirection>I</TransactionDirection>
<DateStamp>2015-03-31</DateStamp>
<TimeStamp>20:08:16</TimeStamp>
<ControlNumber/>
</Prefix>
<Header00>
<TransactionDefinitionKey>25</TransactionDefinitionKey>
<CompanyID0>01</CompanyID0>
<BranchID>1323</BranchID>
<UserID>WMUser</UserID>
<WarehouseID>RS01</WarehouseID>
</Header00>
<Detail01>
<Scanneddata1>01</Scanneddata1>
</Detail01>
<Detail01>
<Scanneddata1>01</Scanneddata1>
</Detail01>
<Detail01>
<Scanneddata1>01</Scanneddata1>
</Detail01>
<Detail02>
<Scanneddata2>1323</Scanneddata2>
</Detail02>
<Detail02>
<Scanneddata2>1323</Scanneddata2>
</Detail02>
<Detail02>
<Scanneddata2>1323</Scanneddata2>
</Detail02>
<Detail03>
<Scanneddata3>930131</Scanneddata3>
</Detail03>
<Detail03>
<Scanneddata3>930131</Scanneddata3>
</Detail03>
<Detail03>
<Scanneddata3>930131</Scanneddata3>
</Detail03>
<Detail04>
<Scanneddata4>1</Scanneddata4>
</Detail04>
<Detail04>
<Scanneddata4>2</Scanneddata4>
</Detail04>
<Detail04>
<Scanneddata4>3</Scanneddata4>
</Detail04>
<Detail05>
<Scanneddata5>RS1412107</Scanneddata5>
</Detail05>
<Detail05>
<Scanneddata5>RS141112</Scanneddata5>
</Detail05>
<Detail05>
<Scanneddata5>RS1412030</Scanneddata5>
</Detail05>
<Detail06>
<Scanneddata6>Hold</Scanneddata6>
</Detail06>
<Detail06>
<Scanneddata6>Hold</Scanneddata6>
</Detail06>
<Detail06>
<Scanneddata6>Hold</Scanneddata6>
</Detail06>
<Detail07>
<Scanneddata7>2015-03-31T20:08:12Z</Scanneddata7>
</Detail07>
<Detail11>
<Scanneddata11>90</Scanneddata11>
</Detail11>
<Detail11>
<Scanneddata11>90</Scanneddata11>
</Detail11>
<Detail11>
<Scanneddata11>90</Scanneddata11>
</Detail11>
</AsyncBarcode>
Was able to figure out what I needed to change. Change shown below:
<xsl:for-each select="n:DataArea/n:ReceiveDelivery/n:ReceiveDeliveryItem/n:HoldCodes[1]">
<Detail06>
<xsl:for-each select="n:Code[1]">
<Scanneddata6>
<xsl:choose>
<xsl:when test="string(('' != string(.))) != 'false'">
<xsl:value-of select="'Hold'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'Inventory'" />
</xsl:otherwise>
</xsl:choose>
</Scanneddata6>
</xsl:for-each>
</Detail06>
</xsl:for-each>

col end tag not getting called

I have the below part of my XML Document. here when i run my xslt on this XML document, the col class ... inside colgroup is getting called, colgroup is getting called but end tag of col class is not getting called. please let me know how do i close col class... the last code contains my html output of xml.
<table frame="all" width="100%">
<tgroup cols="2">
<colspec colnum="1" colname="col1" colwidth="18%"/>
<colspec colnum="2" colname="col2" colwidth="82%"/>
<thead>
<row>
<entry namest="col1" nameend="col2">
<para>A timeline of British Virgin Islands company law</para>
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<para>1884</para>
</entry>
<entry>
<para>Companies Act passed into law.</para>
</entry>
</row>
<row>
<entry>
<para>1984</para>
</entry>
<entry>
<para>International Business Companies Act passed into law.</para>
</entry>
</row>
<row>
<entry>
<para>2004</para>
</entry>
<entry>
<para>BVI Business Companies Act passed into law, coming into force on 1 January 2005.</para>
</entry>
</row>
<row>
<entry>
<para>2005</para>
</entry>
<entry>
<para>All three corporate statutes exist in parallel and it is possible to incorporate companies under any of them.</para>
</entry>
</row>
<row>
<entry>
<para>2006</para>
</entry>
<entry>
<para>Incorporation provisions in the International Business Companies Act and the Companies Act are repealed on 31 December 2005; the Acts remain in force but new companies may only be incorporated under the BVI Business Companies Act.</para>
</entry>
</row>
<row>
<entry>
<para>2007</para>
</entry>
<entry>
<para>International Business Companies Act repealed on 31 December 2006. Transitional provisions come into effect for companies incorporated under that act.</para>
</entry>
</row>
<row>
<entry>
<para>2009</para>
</entry>
<entry>
<para>Companies Act repealed on 31 December 2008. Transitional provisions come into effect for companies incorporated under that Act.</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
and below is my xslt.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ntw="Number2Word.uri"
exclude-result-prefixes="ntw">
<xsl:variable name="ThisDocument" select="document('')"/>
<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8"/>
<title>
<xsl:value-of select="chapter/title"/>
</title>
<link rel="stylesheet" href="er:#css" type="text/css"/>
</head>
<body>
<xsl:apply-templates/>
<hr/>
<section class="tr_footnotes">
<xsl:apply-templates select="//footnote"
mode="footnote"/>
</section>
</body>
</html>
</xsl:template>
<xsl:template match="chapter">
<section>
<div class="chapter">
<a name="BVI-CH-{#num}"/>
<xsl:variable name="cnum">
<xsl:choose>
<xsl:when test="starts-with(#num,'0')">
<xsl:value-of select="substring-after(#num,'0')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="#num"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="chapter-title">
<span class="chapter-num">
<xsl:value-of select="concat('Chapter ',$cnum,' ')"/>
</span>
<xsl:apply-templates select="title"/>
</div>
<xsl:apply-templates select="child::node()[not(self::title)]"/>
</div>
</section>
</xsl:template>
<xsl:template match="chapter/para">
<div class="para align-right">
<span class="format-smallcaps">Para</span>.
</div>
</xsl:template>
<!-- Index templates -->
<xsl:template name="toc" match="chapter/toc">
<div class="toc">
<xsl:call-template name="toc-part"/>
</div>
</xsl:template>
<xsl:template name="toc-part" match="chapter/toc/toc-part">
<div class="toc-part">
<xsl:call-template name="toc-div"/>
</div>
</xsl:template>
<xsl:template name="toc-div" match="chapter/toc/toc-part/toc-div">
<table class="toc-div">
<tbody>
<xsl:for-each select="current()/toc-part/toc-div/*">
<xsl:call-template name="toc-item"/>
</xsl:for-each>
</tbody>
</table>
</xsl:template>
<xsl:template name="toc-item" match="chapter/toc/toc-part/toc-div/toc-item">
<xsl:variable name="tocpg">
<xsl:value-of select="concat('#P',current()/toc-pg/text())"/>
</xsl:variable>
<xsl:variable name="tocpgtag" select="translate($tocpg,'.', '-')"/>
<xsl:variable name="chapternumber">
<!-- Get num attribute of parent node -->
<xsl:value-of select="ancestor::chapter[1]/#num"/>
</xsl:variable>
<xsl:variable name="itemlevel">
<xsl:value-of select="$ThisDocument//ntw:nums[#num=$chapternumber]/#word"/>
</xsl:variable>
<xsl:variable name="tocitemlevel">
<xsl:value-of select="concat('toc-item-', $itemlevel,'-level')"/>
</xsl:variable>
<table class="{$tocitemlevel}">
<tbody>
<tr>
<td class="toc-item-num">
<xsl:value-of select="current()/#num"/>
</td>
<td class="toc-title">
<xsl:value-of select="current()/toc-title"/>
</td>
<td class="toc-pg">
<a href="{$tocpgtag}">
<xsl:value-of select="current()/toc-pg"/>
</a>
</td>
</tr>
</tbody>
</table>
</xsl:template>
<!-- Index Templates Complete -->
<!-- Paragraph templates -->
<xsl:template name="section" match="section">
<!-- Variables-->
<xsl:variable name="classname">
<!--Get name attribute of current node -->
<xsl:value-of select="concat('section-',#level)"/>
</xsl:variable>
<xsl:variable name="chapternumber">
<!-- Get num attribute of parent node -->
<xsl:value-of select="ancestor::chapter[1]/#num"/>
</xsl:variable>
<xsl:variable name="sectnum">
<xsl:number level="any" count="section" format="1"/>
</xsl:variable>
<!--Create a string variable by concat string method -->
<xsl:variable name="sectionname">
<xsl:value-of select="concat('CH-',$chapternumber,'-SEC-0', $sectnum)"/>
</xsl:variable>
<!-- Template Content -->
<div class="{$classname}">
<a name="{$sectionname}"> </a>
<div class="section-title">
<span class="section-num">
<xsl:value-of select="#num"/>
</span>
<xsl:apply-templates select="title"/>
</div>
<xsl:apply-templates select="child::node()[not(self::title)]"/>
</div>
</xsl:template>
<xsl:template name="para" match="section/para">
<div class="para">
<xsl:apply-templates select="phrase"/>
<span class="phrase">
<xsl:value-of select="current()/phrase"/>
</span>
<xsl:apply-templates select="child::node()[not(self::phrase)]"/>
</div>
</xsl:template>
<xsl:template name="phrase" match="phrase">
<xsl:variable name="phrase">
<xsl:value-of select="concat('P',text())"/>
</xsl:variable>
<xsl:variable name="newphrase" select="translate($phrase,'.','-')"/>
<a>
<xsl:attribute name="name"><xsl:value-of select="$newphrase"></xsl:value-of></xsl:attribute>
</a>
</xsl:template>
<!-- Table Templates -->
<xsl:template name="table" match="table">
<table style="frame-{current()/#frame} width-{translate(current()/#width,'%','')}">
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="tgroup">
<colgroup>
<xsl:apply-templates select=".//colspec"/>
</colgroup>
<xsl:apply-templates select="child::node()[not(self::colspec)]"/>
</xsl:template>
<xsl:template name="tbody" match="tgroup/tbody">
<tbody>
<xsl:for-each select="current()/row">
<xsl:call-template name="row"/>
</xsl:for-each>
</tbody>
</xsl:template>
<xsl:template name="thead" match="tgroup/thead">
<xsl:for-each select="current()/row"><thead>
<tr>
<xsl:for-each select="current()/entry">
<xsl:call-template name="headentry"/>
</xsl:for-each>
</tr>
</thead>
</xsl:for-each>
</xsl:template>
<xsl:template name="colspec" match="colspec">
<col class="colnum-{current()/#colnum} colname-{current()/#colname} colwidth-{translate(current()/#colwidth,'%','')}"></col>
</xsl:template>
<xsl:template name="row" match="tbody/row">
<tr>
<xsl:for-each select="current()/entry">
<xsl:call-template name="entry"/>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template name="entry" match="entry">
<xsl:variable name="count">
<xsl:value-of select="count(preceding-sibling::* | following-sibling::*)"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$count < 2">
<xsl:if test="position()=1">
<td>
<div class="para align-center">
<xsl:value-of select="para[position()=1]"/>
</div>
</td>
<td>
<div class="para">
<xsl:value-of select="following-sibling::node()"/>
</div>
</td>
</xsl:if>
</xsl:when>
<xsl:when test="$count > 1">
<td>
<div class="para">
<xsl:apply-templates/>
</div>
</td>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="headentry">
<th>
<xsl:if test="translate(current()/#namest,'col','') != translate(current()/#nameend,'col','')">
<xsl:variable name="colspan">
<xsl:value-of select="translate(current()/#nameend,'col','') - translate(current()/#namest,'col','') + 1"/>
</xsl:variable>
<xsl:attribute name="colspan"><xsl:value-of select="$colspan"></xsl:value-of></xsl:attribute>
</xsl:if>
<div class="para">
<xsl:value-of select="current()/para/text()"/>
</div>
</th>
</xsl:template>
<!-- Table Templates complete -->
<!--List templates -->
<xsl:template name="orderedlist" match="orderedlist">
<ol class="orderedlist">
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template name="orderitem" match="orderlist/item">
<li class="item">
<xsl:apply-templates/>
</li>
</xsl:template>
<xsl:template name="orderitempara" match="item/para">
<xsl:variable name="itemnumber">
<xsl:value-of select="parent::item[1]/#num"/>
</xsl:variable>
<li class="item">
<div class="para">
<span class="item-num">
<xsl:value-of select="parent::item[1]/#num"/>
</span>
<xsl:apply-templates/>
</div>
</li>
</xsl:template>
<!--List templates Complete -->
<!-- Paragraph templates Complete -->
<!-- Footnote Templates-->
<xsl:template match="footnote">
<sup>
<a>
<xsl:attribute name="name"><xsl:text>footnoteref</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
<xsl:attribute name="href"><xsl:text>#footnote</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
<xsl:attribute name="class"><xsl:text>tr_ftn</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
<xsl:number level="any" count="footnote" format="1"/>
</a>
</sup>
</xsl:template>
<xsl:template match="footnote" mode="footnote">
<sup>
<li style="list-style-type:none;indent:0">
<a>
<xsl:attribute name="name"><xsl:text>footnote</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
<xsl:attribute name="href"><xsl:text>#footnoteref</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
<xsl:attribute name="class"><xsl:text>tr_ftn</xsl:text><xsl:number level="any" count="footnote" format="1"/></xsl:attribute>
<xsl:number level="any" count="footnote" format="1"/>
</a>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
</li>
</sup>
</xsl:template>
<xsl:template match="footnote/para/uri">
<xsl:variable name="url1">
<xsl:value-of select="translate(#href, '<','')" />
</xsl:variable>
<xsl:variable name="url2">
<xsl:value-of select="translate($url1, '>','')" />
</xsl:variable>
<a href="{$url2}">
<xsl:value-of select="." />
</a>
</xsl:template>
<!-- Footnote Templates Complete -->
<xsl:template match="content-style">
<xsl:choose>
<xsl:when test="#format='smallcaps'">
<xsl:value-of select="translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXZ','abcdefghijklmnopqrstuvwxyz')"/>
</xsl:when>
<xsl:when test="#format='superscript'">
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Namespace ntw-->
<ntw:nums num="01" word="first"/>
<ntw:nums num="02" word="second"/>
<ntw:nums num="03" word="third"/>
<ntw:nums num="04" word="forth"/>
<ntw:nums num="05" word="fifth"/>
<ntw:nums num="06" word="sixth"/>
<ntw:nums num="07" word="seventh"/>
<ntw:nums num="08" word="eighth"/>
<ntw:nums num="09" word="nighth"/>
<ntw:nums num="10" word="tenth"/>
<!-- Namespace ntw ends -->
</xsl:stylesheet>
HTML output of xml.
table style="frame-all width-100">
<colgroup>
<col class="colnum-1 colname-col1 colwidth-18"> //here / is missing in the end
<col class="colnum-2 colname-col2 colwidth-82">//here / is missing in the end
</colgroup>
Thanks
Welcome to Stack Overflow!
Your stylesheet does not specify an output method, but your output is recognizably HTML. So your stylesheet is using the HTML output method, and not the XML output method. In the HTML output method, elements which are always empty (like col) use an SGML-style end-tag, so the output you show is correct.
If you want XML output, add an xsl:output element to the stylesheet (as the first child of xsl:stylesheet) and specify method="xml" on it, thus:
<xsl:output method="xml"/>
(Note that if you are looking to create XHTML output, you will want to put your output elements in the XHTML namespace.)
When I add an output element to the stylesheet, the colgroup element in the output takes the following form, which appears to be what you're looking for:
<colgroup>
<col class="colnum-1 colname-col1 colwidth-18"/>
<col class="colnum-2 colname-col2 colwidth-82"/>
</colgroup>