Hi All

I have an XML output that looks similar to the below ...

<ELEC01_SOWaitingParts3>
    <JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OprSeq><![CDATA[60]]></JobOper_OprSeq>
    <JobOper_OpCode><![CDATA[A/W]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[ACID/WASH]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OprSeq><![CDATA[70]]></JobOper_OprSeq>
    <JobOper_OpCode><![CDATA[INSP A/W]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[INSP ACID/WASH]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OprSeq><![CDATA[80]]></JobOper_OprSeq>
    <JobOper_OpCode><![CDATA[GET F/L]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[GET FITTING LID]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OprSeq><![CDATA[90]]></JobOper_OprSeq>
    <JobOper_OpCode><![CDATA[KIT F/L]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[KIT FITTING LID]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
  </ELEC01_SOWaitingParts3>

As you can see, the JobOper_JobNum is the same for each of the above (bear in mind this is only an extract, the full XML contains lots of different JobOper_JobNum's).

In the second line you can see 'JobOper_OprSeq' - 60, 70, 80, 90

However when the xml is converted into html via XSL, I only want to see the first entry for each JobOper_JobNum.

So in the above case, I only want the following to be displayed in my final output ...

<ELEC01_SOWaitingParts3>
    <JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OprSeq><![CDATA[60]]></JobOper_OprSeq>
    <JobOper_OpCode><![CDATA[A/W]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[ACID/WASH]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
  </ELEC01_SOWaitingParts3>

I want this to be the case for ALL of the different JobOper_JobNum - I only want to see the first entry and they will always be output in sequential order (10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140 etc).

Any help would be massively aprpeciated.

Thanks.

So a input document can contain multiple "SOWaitingParts3" elements, that have the SAME JobOper_JobNum. And each JobOper_JobNum could have multiple "JobOper_OprSeq" elements? And you always want to see the sequence with the lowest number in the JobOper_OprSeq element?

XSLt 1.0 or 2.0?

hi, you need something like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
    exclude-result-prefixes="xd"
    version="1.0">
    <xsl:output indent="yes"/>
    <xsl:template match="/">
        <root>
        <xsl:for-each select="root/ELEC01_SOWaitingParts3[not(JobOper_JobNum = preceding::JobOper_JobNum)]">
            <xsl:copy-of select="."/>
        </xsl:for-each>
        </root>
    </xsl:template>
</xsl:stylesheet>

Cheers, John Bampton.

Your suggestion works a treat.

Now I just need to get the results to display in a table.

If I dont want to see all columns in a table, what do I have to do to only show certain columns?

E.g. I only want to see ...

<JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OpDesc><![CDATA[ACID/WASH]]></JobOper_OpDesc>

think xsl

so you can use predicate as if structur and param for extern xsl prozessor
to controled which one is select or you can hardcode which is the right positon

to make valid i use root tag

<root>
	<ELEC01_SOWaitingParts3>
		<JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
		<JobOper_OprSeq><![CDATA[60]]></JobOper_OprSeq>
		<JobOper_OpCode><![CDATA[A/W]]></JobOper_OpCode>
		<JobOper_OpDesc><![CDATA[ACID/WASH]]></JobOper_OpDesc>
		<JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
		<JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
	</ELEC01_SOWaitingParts3>
	<ELEC01_SOWaitingParts3>
		<JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
		<JobOper_OprSeq><![CDATA[70]]></JobOper_OprSeq>
		<JobOper_OpCode><![CDATA[INSP A/W]]></JobOper_OpCode>
		<JobOper_OpDesc><![CDATA[INSP ACID/WASH]]></JobOper_OpDesc>
		<JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
		<JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
	</ELEC01_SOWaitingParts3>
	<ELEC01_SOWaitingParts3>
		<JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
		<JobOper_OprSeq><![CDATA[80]]></JobOper_OprSeq>
		<JobOper_OpCode><![CDATA[GET F/L]]></JobOper_OpCode>
		<JobOper_OpDesc><![CDATA[GET FITTING LID]]></JobOper_OpDesc>
		<JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
		<JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
	</ELEC01_SOWaitingParts3>
	<ELEC01_SOWaitingParts3>
		<JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
		<JobOper_OprSeq><![CDATA[90]]></JobOper_OprSeq>
		<JobOper_OpCode><![CDATA[KIT F/L]]></JobOper_OpCode>
		<JobOper_OpDesc><![CDATA[KIT FITTING LID]]></JobOper_OpDesc>
		<JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
		<JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
	</ELEC01_SOWaitingParts3>
</root>

not use for-each think xslt
predicate is use [] xpath has funktion position() and last()
so can write for the second ELEC01_SOWaitingParts3[position()=$pos]
or ELEC01_SOWaitingParts3[$pos]
when you will the last
ELEC01_SOWaitingParts3[position()=last()]

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="xml"/>
        <!--hardcode use first -->
	<xsl:param name="pos" select="1"/>
	<xsl:template match="/">
		<xsl:apply-templates select="root"/>
	</xsl:template>
	<xsl:template match="root">
		<xsl:apply-templates select="ELEC01_SOWaitingParts3[$pos]"/>
	</xsl:template>
	<xsl:template match="ELEC01_SOWaitingParts3">
		<xsl:copy-of select="."/>
	</xsl:template>
</xsl:stylesheet>

result

<ELEC01_SOWaitingParts3>
		<JobOper_JobNum>019564</JobOper_JobNum>
		<JobOper_OprSeq>60</JobOper_OprSeq>
		<JobOper_OpCode>A/W</JobOper_OpCode>
		<JobOper_OpDesc>ACID/WASH</JobOper_OpDesc>
		<JobOper_OpComplete>No</JobOper_OpComplete>
		<JobOper_QtyCompleted>0.00</JobOper_QtyCompleted>
	</ELEC01_SOWaitingParts3>

How can I get it so it displays neatly in a table with a JobHead_JobNum per line?

I am using this to display the results ...

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes"/>

<xsl:template match="/">


<html>
<body>
    <table cellpadding="4px">
      <tr>
	<td align="center"><B1>Customer</B1></td>
        <td align="center"><B1>Order No.</B1></td>
</tr>

        <root>
        <xsl:for-each select="ExportQuery/ELEC01_SOWaitingParts3[not(JobOper_JobNum = 

preceding::JobOper_JobNum)]">
           <xsl:copy-of select="."/>


<tr>

	<td align="center"><xsl:value-of select="JobHead_JobNum"/></td>
        <td align="center"><xsl:value-of select="JobOper_OpDesc"/></td>

</tr>

        </xsl:for-each>
        </root>
</table>
</body>
</html>

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

However, it displays the correct results in a table at the bottom of the document, but at the top of the document it is displaying random text from the XML.

think xsl
use not for-each

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="html"/>
	<xsl:param name="pos" select="1"/>
	<xsl:template match="/">
		<xsl:apply-templates select="root"/>
	</xsl:template>
	<xsl:template match="root">
		<html>
			<style type="text/css">
			table{
			border: 2px solid black;
			}
			th,td{
                        border: 2px solid black;
                        padding: 30px;
			}
			td{
			text-align: center;
			}
			</style>
			<body>
				<table>
					<tr>
                                                <!--
						<th>
						</th>
                                                -->
						<th>Customer</th>
						<th>Order No.</th>
					</tr>
					<xsl:apply-templates select="ELEC01_SOWaitingParts3[$pos]"/>
				</table>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="ELEC01_SOWaitingParts3">
		<!--
		<xsl:copy-of select="."/>
	     -->
		<tr>
			<td>
				<xsl:value-of select="JobOper_JobNum"/>
			</td>
			<td>
				<xsl:value-of select="JobOper_OpDesc"/>
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet>

result

<html>
  <style type="text/css">
			table{
			border: 2px solid black;
			}
			th,td{
            border: 2px solid black;
            padding: 30px;
			}
			td{
			text-align: center;
			}
			
  </style>
  <body>
    <table>
      <tr>
        <th>Customer</th>
        <th>Order No.</th>
      </tr>
      <tr>
        <td>019564</td>
        <td>ACID/WASH</td>
      </tr>
    </table>
  </body>
</html>

Hi All

Im still struggling with this a bit.

Here is an extract of my XML file ...

<ExportQuery>
 <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE1/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[02/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[019830]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[20]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE1/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19288]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19288]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[TCE1/75-P304]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[019830]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[CHECK PR]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[CHECK PROGRAMME]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[19830]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE1/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[02/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[019830]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[30]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE1/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19288]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19288]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[TCE1/75-P304]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[019830]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[BREAK OU]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[BREAK OUT]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[19830]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE1/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[02/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[019830]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[40]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE1/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19288]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19288]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[TCE1/75-P304]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[019830]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[LINNISH]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[LINNISH]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[19830]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE1/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[02/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[019885]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[30]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE1/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19288]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19288]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[TCE1/75-P304]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[019885]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[BREAK OU]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[BREAK OUT]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[19830]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE1/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[02/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[019885]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[40]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE1/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19288]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19288]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[TCE1/75-P304]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[019885]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[LINNISH]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[LINNISH]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[19830]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE1/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[05/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[019830]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[20]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE1/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19292]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19292]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[TCE1/75-P304]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[019830]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[CHECK PR]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[CHECK PROGRAMME]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[19830]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE1/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[05/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[019830]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[30]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE1/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19292]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19292]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[TCE1/75-P304]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[019830]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[BREAK OU]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[BREAK OUT]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[19830]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE1/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[05/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[019830]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[40]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE1/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19292]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19292]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[TCE1/75-P304]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[019830]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[LINNISH]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[LINNISH]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[19830]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE1/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[05/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[019885]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[30]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE1/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19292]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19292]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[TCE1/75-P304]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[019885]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[BREAK OU]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[BREAK OUT]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[19830]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE1/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[05/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[019885]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[40]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE1/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19292]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19292]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[TCE1/75-P304]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[019885]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[LINNISH]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[LINNISH]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[19830]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
<ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[TCE2/75-P304]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[02/03/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[TCE2/75-P304]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[19288]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[19288]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
<ExportQuery>

As you can see from the above, although OrderDtl_PartNum is the same, OrderDtl_OrderNum can be different.

The last block of data contains another OrderDtl_PartNum, but this does not have any JOB data.

Each OrderDtl_PartNum may have more than one JobHead_JobNum (or some may have no JobHead_JobNum).

Each JobHead_JobNum may have several JobOper_OrpSeq.

I want my XSL to display the following in a table:

OrderDtl_OrderNum - This is the individual order number.

OrderDtl_PartNum -
This is a part on the above order (if the order has several lines, these details will be repeated in the table)

JobHead_JobNum -
This is a Job assinged to the part in the order. If there are several jobs for the same part, these details will be repeated in the table.

JobOper_OprSeq -
I only want the FIRST JobOper_OprSeq to be shown for each JobHead_JobNum. E.g. In the above data, JobHead_JobNum has JobOper_OprSeq 20, 30, 40, 50 etc - I only want to see JobOper_OprSeq 20.

I also want them to be filtered by OrderHead_RequestDate with the oldest date first and the newest data last.

EXPECTED OUTCOME:

RequestDate | OrderDtl_OrderNum | OrderDtl_OrderPart | JobHead_JobNum | JobOper_OprSeq

02/03/2011 19288 TCE1/75-P304 019830 20
02/03/2011 19288 TCE1/75-P304 019885 30
02/03/2011 19288 TCE2/75-P304
05/03/2011 19292 TCE1/75-P304 019830 20
05/03/2011 19292 TCE1/75-P304 019885 30

So above we can see that TCE1/75-P304 is on orders 19288 and 19292.

There are two Jobs out for TCE1/75-P304 (Job 019830 and 019885).

Job 019830 is at stage 20 (the first JobOper_OprSeq available in the XML).

Job 019830 is at stage 30 (the first JobOper_OprSeq available in the XML).

TCE2/75-P304 is also on OrderDtl_OrderNum 19288 but there are no jobs linked to this part.

The list is sorted by the RequestDate Low -> High.

Does anyone have any suggestions and examples to get this to work like this?

hello
i have problem to understand
the rule of selection
see picture

So a input document can contain multiple "SOWaitingParts3" elements, that have the SAME JobOper_JobNum. And each JobOper_JobNum could have multiple "JobOper_OprSeq" elements? And you always want to see the sequence with the lowest number in the JobOper_OprSeq element?

XSLt 1.0 or 2.0?

This is an example of the XML:

<ExportQuery>
  <ELEC01_SOWaitingParts3>
    <OrderDtl_PartNum><![CDATA[UK MUNSTD 20 BOX OF 100]]></OrderDtl_PartNum>
    <OrderHed_RequestDate><![CDATA[17/02/11]]></OrderHed_RequestDate>
    <JobHead_JobNum><![CDATA[018957]]></JobHead_JobNum>
    <JobOper_OprSeq><![CDATA[10]]></JobOper_OprSeq>
    <Part_PartNum><![CDATA[UK MUNSTD 20 BOX OF 100]]></Part_PartNum>
    <OrderDtl_OrderNum><![CDATA[18432]]></OrderDtl_OrderNum>
    <OrderHed_OrderNum><![CDATA[18432]]></OrderHed_OrderNum>
    <JobHead_PartNum><![CDATA[UK MUNSTD 20 BOX OF 100]]></JobHead_PartNum>
    <JobHead_JobComplete><![CDATA[No]]></JobHead_JobComplete>
    <JobOper_JobNum><![CDATA[018957]]></JobOper_JobNum>
    <JobOper_OpCode><![CDATA[GB STORE]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[GET BATCH STORES]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
    <FalseJobNum><![CDATA[18957]]></FalseJobNum>
  </ELEC01_SOWaitingParts3>
</ExportQuery>

The input document has multiple ELEC01_SOWaitingParts (one for each block).

Each OrderDtl_OrderNum can have multiple OrderDtl_PartNum.

Each OrderDtl_PartNum can have multiple JobOper_JobNum.

Each JobOper_JobNum can have multiple JobOper_OprSeq.

Each JobOpr_OprSeq can have JobOpr_OpComplete as either YES or NO.


I need to see the FIRST JobOper_OprSeq for EACH JobOper_JobNum against EACH OrderDtl_PartNum where the JobOpr_OpComplete = No.


I dont want to see a JobOp_Complete = YES.

I would expect to see the same line repeated throughout the results if there are more than one OrderDtl_OrderNum with the same OrderDtl_OrderNum.

hello
i have problem to understand
the rule of selection
see picture

Based on your image, I would only expect to see line 1, 4, 6, 7, 10 in my results.

Hi All

I have an XML output that looks similar to the below ...

<ELEC01_SOWaitingParts3>
    <JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OprSeq><![CDATA[60]]></JobOper_OprSeq>
    <JobOper_OpCode><![CDATA[A/W]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[ACID/WASH]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OprSeq><![CDATA[70]]></JobOper_OprSeq>
    <JobOper_OpCode><![CDATA[INSP A/W]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[INSP ACID/WASH]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OprSeq><![CDATA[80]]></JobOper_OprSeq>
    <JobOper_OpCode><![CDATA[GET F/L]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[GET FITTING LID]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
  </ELEC01_SOWaitingParts3>
  <ELEC01_SOWaitingParts3>
    <JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OprSeq><![CDATA[90]]></JobOper_OprSeq>
    <JobOper_OpCode><![CDATA[KIT F/L]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[KIT FITTING LID]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
  </ELEC01_SOWaitingParts3>

As you can see, the JobOper_JobNum is the same for each of the above (bear in mind this is only an extract, the full XML contains lots of different JobOper_JobNum's).

In the second line you can see 'JobOper_OprSeq' - 60, 70, 80, 90

However when the xml is converted into html via XSL, I only want to see the first entry for each JobOper_JobNum.

So in the above case, I only want the following to be displayed in my final output ...

<ELEC01_SOWaitingParts3>
    <JobOper_JobNum><![CDATA[019564]]></JobOper_JobNum>
    <JobOper_OprSeq><![CDATA[60]]></JobOper_OprSeq>
    <JobOper_OpCode><![CDATA[A/W]]></JobOper_OpCode>
    <JobOper_OpDesc><![CDATA[ACID/WASH]]></JobOper_OpDesc>
    <JobOper_OpComplete><![CDATA[No]]></JobOper_OpComplete>
    <JobOper_QtyCompleted><![CDATA[0.00]]></JobOper_QtyCompleted>
  </ELEC01_SOWaitingParts3>

I want this to be the case for ALL of the different JobOper_JobNum - I only want to see the first entry and they will always be output in sequential order (10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140 etc).

Any help would be massively aprpeciated.

Thanks.

I actually only want to see the first JobOper_OprSeq for each JobOper_JobNum where the JobOper_Complete = No.

I dont want to see any JobOper_Complete = Yes.

hi, you need something like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
    exclude-result-prefixes="xd"
    version="1.0">
    <xsl:output indent="yes"/>
    <xsl:template match="/">
        <root>
        <xsl:for-each select="root/ELEC01_SOWaitingParts3[not(JobOper_JobNum = preceding::JobOper_JobNum)]">
            <xsl:copy-of select="."/>
        </xsl:for-each>
        </root>
    </xsl:template>
</xsl:stylesheet>

Cheers, John Bampton.

This almost works, except JobOper_JobNum may be displayed several times in the XML.

The full XML actually contains OrderHed_OrderNum and OrderDtl_PartNum.

Each OrderHed_OrderNum has one or more OrderDtl_PartNum assigned.

Each OrderDtl_PartNum may have (but not always) one or more JobOper_JobNum assigned.

I want to be able to see EVERY OrderHed_OrderNum and OrderDtl_PartNum assigned to each.

I then want to see the JobOper_JobNum for EACH OrderDtl_PartNum.

I then want to see the FIRST JobOper_OprSeq for EACH JobOper_JobNum.


The same JobOper_JobNum and JobOper_OprSeq may appear several times throughout the results.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:key match="ELEC01_SOWaitingParts3" name="only" use="concat(OrderHed_RequestDate,OrderDtl_PartNum,JobHead_JobNum)"/>
	<xsl:output indent="yes" method="html"/>
	<xsl:template match="/">
		<html>
			<style>table {
border: 2px solid black;
}
th,td{
border: 2px solid black;
}
tr{
text-align: center;
}
tr.head{
text-align: left;
background-color:#ff0000;
}
tr.odd{
background-color:#ff9900;
}
tr.even{
background-color:#ff0099;

}</style>
			<xsl:apply-templates select="ExportQuery"/>
		</html>
	</xsl:template>
	<xsl:template match="ExportQuery">
		<table>
			<tr class="head">
				<th>Pos</th>
				<th>RequestDate</th>
				<th>OrderDtl_OrderNum</th>
				<th>OrderDtl_OrderPart</th>
				<th>JobHead_JobNum</th>
				<th>JobOper_OprSeq</th>
			</tr>
			<xsl:for-each select="ELEC01_SOWaitingParts3[generate-id() = generate-id(key('only', concat(OrderHed_RequestDate,OrderDtl_PartNum,JobHead_JobNum))[1])]">
				<xsl:sort select="OrderHed_RequestDate"/>
				<xsl:variable select="OrderHed_RequestDate" name="date"/>
				<tr>
					<xsl:choose>
						<xsl:when test="position() mod 2 = 1">
							<xsl:attribute name="class">odd</xsl:attribute>
						</xsl:when>
						<xsl:when test="position() mod 2 = 0">
							<xsl:attribute name="class">even</xsl:attribute>
						</xsl:when>
					</xsl:choose>
					<td>
						<xsl:value-of select="position()"/>
					</td>
					<td>
						<xsl:variable name="day" select="substring(OrderHed_RequestDate,1,2)"/>
						<xsl:variable name="mon" select="substring(OrderHed_RequestDate,4,2)"/>
						<xsl:variable name="year" select="substring(OrderHed_RequestDate,7,2)"/>
						<xsl:value-of select="concat('am ',$day,'.',$mon,'.20',$year)"/>
					</td>
					<td>
						<xsl:value-of select="OrderDtl_OrderNum"/>
					</td>
					<td>
						<xsl:value-of select="OrderDtl_PartNum"/>
					</td>
					<td>
						<xsl:value-of select="JobHead_JobNum"/>
					</td>
					<td>
						<xsl:value-of select="JobOper_OprSeq"/>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>
</xsl:stylesheet>

result

<html>
  <style>table {
border: 2px solid black;
}
th,td{
border: 2px solid black;
}
tr{
text-align: center;
}
tr.head{
text-align: left;
background-color:#ff0000;
}
tr.odd{
background-color:#ff9900;
}
tr.even{
background-color:#ff0099;

}
  </style>
  <table>
    <tr class="head">
      <th>Pos</th>
      <th>RequestDate</th>
      <th>OrderDtl_OrderNum</th>
      <th>OrderDtl_OrderPart</th>
      <th>JobHead_JobNum</th>
      <th>JobOper_OprSeq</th>
    </tr>
    <tr class="odd">
      <td>1</td>
      <td>am 02.03.2011</td>
      <td>19288</td>
      <td>TCE1/75-P304</td>
      <td>019830</td>
      <td>20</td>
    </tr>
    <tr class="even">
      <td>2</td>
      <td>am 02.03.2011</td>
      <td>19288</td>
      <td>TCE1/75-P304</td>
      <td>019885</td>
      <td>30</td>
    </tr>
    <tr class="odd">
      <td>3</td>
      <td>am 02.03.2011</td>
      <td>19288</td>
      <td>TCE2/75-P304</td>
      <td></td>
      <td></td>
    </tr>
    <tr class="even">
      <td>4</td>
      <td>am 05.03.2011</td>
      <td>19292</td>
      <td>TCE1/75-P304</td>
      <td>019830</td>
      <td>20</td>
    </tr>
    <tr class="odd">
      <td>5</td>
      <td>am 05.03.2011</td>
      <td>19292</td>
      <td>TCE1/75-P304</td>
      <td>019885</td>
      <td>30</td>
    </tr>
  </table>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.