Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 658355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:55:28+00:00 2026-05-13T22:55:28+00:00

I have the following XML and I want to process it so that I

  • 0

I have the following XML and I want to process it so that I do not get duplicates in the result set. I have simplified the problem to make it easier to understand. Also how can I use the results of one template as part of the input for another?

This:

<LINES xmlns:set="http://exslt.org/sets">
  <STDINSTRSEQ>0</STDINSTRSEQ>
  <STDINSTRSEQ>1</STDINSTRSEQ>
  <STDINSTRSEQ>2</STDINSTRSEQ>
</LINES>

is the desired result. <STDINSTRSEQ> is the name of the field that should be treated as the key. I have provided the sample data here.

<PURCHASEORDER>
  <POHEADER>
    <REQUISITIONNO>1103025T12 000 000</REQUISITIONNO>
    <REQLDATE>2004-10-26</REQLDATE>
    <MTLREQDT></MTLREQDT>
    <CREATEDT>2005-03-16</CREATEDT>
    <VNDRLONGNM>DORI FOODS, INC.</VNDRLONGNM>
  </POHEADER>
  <LINES>
    <LINE>
      <POLINENBR>12</POLINENBR>
      <STDINSTRDESC>NOTE: THIS PURCHASE ORDER SERVES AS CONFIRMATION</STDINSTRDESC>
      <STDINSTRSEQ>0</STDINSTRSEQ>
    </LINE>
    <LINE>
      <POLINENBR>11</POLINENBR>
      <STDINSTRDESC>NOTE: THIS PURCHASE ORDER SERVES AS CONFIRMATION</STDINSTRDESC>
      <STDINSTRSEQ>0</STDINSTRSEQ>
    </LINE>
    <LINE>
      <POLINENBR>11</POLINENBR>
      <STDINSTRDESC>THAT WE ACCEPT THE TERMS AND CONDITIONS OUTLINED IN</STDINSTRDESC>
      <STDINSTRSEQ>1</STDINSTRSEQ>
    </LINE>
    <LINE>
      <POLINENBR>12</POLINENBR>
      <STDINSTRDESC>THAT WE ACCEPT THE TERMS AND CONDITIONS OUTLINED IN</STDINSTRDESC>
      <STDINSTRSEQ>1</STDINSTRSEQ>
    </LINE>
    <LINE>
      <POLINENBR>23</POLINENBR>
      <STDINSTRDESC>YOUR CONTRACT DATED 02/16/2007 FOR THE FOLLOWING</STDINSTRDESC>
      <STDINSTRSEQ>2</STDINSTRSEQ>
    </LINE>
    <LINE>
      <POLINENBR>22</POLINENBR>
      <STDINSTRDESC>YOUR CONTRACT DATED 02/16/2007 FOR THE FOLLOWING</STDINSTRDESC>
      <STDINSTRSEQ>2</STDINSTRSEQ>
    </LINE>
  </LINES>
</PURCHASEORDER>
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:55:28+00:00Added an answer on May 13, 2026 at 10:55 pm

    If I understand correctly what you are asking for, then given your sample XML this would work

    <?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" encoding="UTF-8" indent="yes"/>
    
      <xsl:template match="/">
        <xsl:apply-templates select="/PURCHASEORDER/LINES" />
      </xsl:template>
    
      <xsl:template match="LINES">
        <LINES xmlns:set="http://exslt.org/sets">
               <xsl:apply-templates select="LINE/STDINSTRSEQ[not(. = preceding::STDINSTRSEQ)]"/> 
        </LINES>
      </xsl:template>
    
      <xsl:template match="STDINSTRSEQ">
              <xsl:copy> <xsl:apply-templates/> </xsl:copy>
      </xsl:template>
    
    </xsl:stylesheet>
    

    An optimized version that uses <xsl:key> to filter and provide unique 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="xml" encoding="UTF-8" indent="yes"/>
    
      <xsl:key name="STDIN" match="STDINSTRSEQ" use="./text()" />
    
      <xsl:template match="/">
        <xsl:apply-templates select="/PURCHASEORDER/LINES" />
      </xsl:template>
    
      <xsl:template match="LINES">
        <LINES xmlns:set="http://exslt.org/sets">
               <xsl:apply-templates select="LINE/STDINSTRSEQ[generate-id(.) = generate-id(key('STDIN', .))]"/>
        </LINES>
      </xsl:template>
    
      <xsl:template match="STDINSTRSEQ">
              <xsl:copy> <xsl:apply-templates/> </xsl:copy>
      </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following xml as a response to a service not i want to
I have the following xml format that i want to bind it through a
I have XML in the following form that I want to parse with PHP
I have the following REST get Request that works successfully: The result is a
I have following xml and I want to fetch the value of node which
I have the following XML <title> This is a <highlight>test</highlight> thanks. </title> and want
Let's say I have the following XML: <Account> <AccountExpirationDate>6/1/2009</AccountExpirationDate> </Account> I want to use
I have XML in the following format which I want to reformat: <blocks> <!--
I want to know that I have the string.xml Resource file which contains status
I have the following xml and want to insert additional xml into it: <root>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.