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 4613056
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:29:31+00:00 2026-05-22T01:29:31+00:00

My input file, <?xml version=1.0 encoding=UTF-8?> <TstData> <ENT_A_BLY Common_Key=3195 KG NAME=COMPDATA_AC/> <SOLUTIONS> <A_BLY Name=LPT

  • 0

My input file,

<?xml version="1.0" encoding="UTF-8"?>
<TstData>
<ENT_A_BLY Common_Key="3195  KG" NAME="COMPDATA_AC"/>
<SOLUTIONS>
    <A_BLY Name="LPT nozzle cracked." Common_Key="489BB8CC-5978-4D45-B781-929703D1826A">
        <SOLUTION>
            <ID>2060000000000000000001309</ID>
            <TITLE Common_Key="FD08B464-B115-433F-82A9-0B2BC5CC0A4E"> LPT(Low Pressure Turbine) Damage</TITLE>
        </SOLUTION>
        <SOLUTION>
            <ID>206000000000000000001310</ID>
            <TITLE Common_Key="FFDSFE64-8DF9-43RF-8DF9-0DFSD5CC0A4E"> LPT(Low Pressure Turbine) Damage</TITLE>
        </SOLUTION>
        <SOLUTION>
            <ID>2060000000000000000001316</ID>
            <TITLE Common_Key="ADUIEI42-B115-433F-82A9-0B2BC5CC0A4E">Temperature High due to LPT(Low Pressure Turbine) Damage</TITLE>
        </SOLUTION>     
    </A_BLY>
</SOLUTIONS>
</TstData>

In the XSLT, I am trying to fetch only one TITLE text from the 2 solutions.(as both the TITLE names are same.) so that no duplicate data will be displayed in the output.

My XSLT.. (part shown).

<xsl:element name="FMs">
<xsl:variable name="distinctFM" select="distinct-values(//SOLUTION/TITLE/@Common_Key)"/>
<xsl:for-each select="$distinctFM">
    <xsl:variable name="TITLENAME" select="."/>
    <xsl:variable name="TITLENAME1" select="//SOLUTIONS/A_BLY/SOLUTION/TITLE[@Common_Key=$TITLENAME]"/>
    <xsl:element name="FailureMode">
        <xsl:attribute name="CommonKey"><xsl:value-of select="$TITLENAME"/></xsl:attribute>
        <xsl:attribute name="FMName"><xsl:value-of select="substring(normalize-space($TITLENAME1),1,200)"/></xsl:attribute>
    </xsl:element>
</xsl:for-each>
</xsl:element>

I am expecting the output in this format,

<FM CommonKey="FD08B464-B115-433F-82A9-0B2BC5CC0A4E" FMName="LPT(Low Pressure Turbine) Damage"/>
<FM CommonKey="ADUIEI42-B115-433F-82A9-0B2BC5CC0A4E" FMName="Temperature High due to LPT(Low Pressure Turbine) Damage"/>

But, currently while I debugged, for FMName, it throws error at Variable TITLENAME1. Pls help me in framing this output.

Thanks
Ramm

  • 1 1 Answer
  • 0 Views
  • 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-22T01:29:32+00:00Added an answer on May 22, 2026 at 1:29 am

    Try this:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="SOLUTIONS">
        <FMs>
          <xsl:apply-templates />
        </FMs>
      </xsl:template>
    
      <xsl:template match="SOLUTION">
        <FailureMode CommonKey="{TITLE/@Common_Key}" FMName="{TITLE}" />
      </xsl:template>
    
      <xsl:template match="SOLUTION[preceding-sibling::SOLUTION/TITLE = TITLE]" />
    </xsl:stylesheet>
    

    The last template basically overrides the previous one where there’s a previous SOLUTION node with the same title as the current one, and outputs nothing.

    Alternatively, it can be done using a key:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:key name="FMName" match="SOLUTION" use="TITLE" />
    
      <xsl:template match="SOLUTIONS">
        <FMs>
          <xsl:apply-templates />
        </FMs>
      </xsl:template>
    
      <xsl:template match="SOLUTION">
        <xsl:if test="generate-id() = generate-id(key('FMName',TITLE)[1])">
          <FailureMode CommonKey="{TITLE/@Common_Key}" FMName="{TITLE}" />
        </xsl:if>
      </xsl:template>
    </xsl:stylesheet>
    

    This solution uses an xsl:if to only include nodes that are the first node with the given name.

    In this case, I’d recommend the first method personally, but the latter can be more flexible with a more complex XML structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a input file Main.xml <?xml version=1.0 encoding=utf-8 ?> <Employees> <Employee> <id name=id>1</id>
I'm using this wsdl-file to describe my webservice: <?xml version=1.0 encoding=UTF-8 ?> <wsdl:definitions targetNamespace=http://www.myapproach.de/knowledgebase
I have the following XML file: <?xml version='1.0' encoding='utf-8'?> <Answers> <Question1 q=What is your
I have the following XML file: <?xml version='1.0' encoding='utf-8'?> <Answers> <Question1 q=What is your
I have got below xml format file called ResourceData.xml . <?xml version=1.0 encoding=utf-8 ?>
My XML file is like.. <?xml version=1.0 encoding=utf-8 ?> <Controls> <Control ToValidate=0 ControlID=cmbTrialType ControlType=FormControl
I have generated this WSDL file... <?xml version=1.0 encoding=UTF-8 standalone=yes?> <!-- Generated by JAX-WS
I have the following small file to reproduce the warning: <?xml version=1.0 encoding=UTF-8?> <beans
Test.xml: <?xml version=1.0 encoding=UTF-8?> <node>line1 line2 line3</node> CF code: <cfset xmlfile = ExpandPath(test.xml)> <cffile
I have an XML input file and I'm trying to output the result of

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.