I have an xml as:
<?xml version="1.0" encoding="UTF-16"?><SiebelMessage
MessageId="1-2WPBF"
IntObjectName="LHC Rules Items IO"
MessageType="Integration Object"
IntObjectFormat="Siebel Hierarchical"
><ListOfLhcRulesItemsBo
><LhcRuleItems
><Comments
>Pick@Unique</Comments
><Level
>3</Level
><Id
>1-2BCN3B</Id
><Branch
>Civil</Branch
><Category
>C.M. (Civil)</Category
><Rule
>Bench Type</Rule
><SubCategory
>Pauper</SubCategory
><Value
>Divisional</Value
></LhcRuleItems
><LhcRuleItems
><Comments
>Pick@Unique</Comments
><Level
>3</Level
><Id
>1-2BFEH7</Id
><Branch
>Civil</Branch
><Category
>C.M. (Civil)</Category
><Rule
>Court Fee</Rule
><SubCategory
>Pauper</SubCategory
><Value
>1</Value
></LhcRuleItems
><LhcRuleItems
><Comments
>Pick@Ignore</Comments
><Level
>2</Level
><Id
>1-2BIJY8</Id
><Branch
>Civil</Branch
><Category
>C.M. (Civil)</Category
><Rule
>Bench Type</Rule
><SubCategory
></SubCategory
><Value
>Single</Value
></LhcRuleItems
><LhcRuleItems
><Comments
>Pick@Ignore</Comments
><Level
>2</Level
><Id
>1-2BIJY9</Id
><Branch
>Civil</Branch
><Category
>C.M. (Civil)</Category
><Rule
>Court Fee</Rule
><SubCategory
></SubCategory
><Value
>200</Value
></LhcRuleItems
><LhcRuleItems
><Comments
>Pick@Ignore</Comments
><Level
>1</Level
><Id
>1-2BIRER</Id
><Branch
>Civil</Branch
><Category
></Category
><Rule
>Bench Type</Rule
><SubCategory
></SubCategory
><Value
>Single</Value
></LhcRuleItems
><LhcRuleItems
><Comments
>Pick@Ignore</Comments
><Level
>1</Level
><Id
>1-2BIRET</Id
><Branch
>Civil</Branch
><Category
></Category
><Rule
>Court Fee</Rule
><SubCategory
></SubCategory
><Value
>100</Value
></LhcRuleItems
><LhcRuleItems
><Comments
>Pick@Unique</Comments
><Level
>2</Level
><Id
>1-2BISGB</Id
><Branch
>Civil</Branch
><Category
>C.M. (Civil)</Category
><Rule
>Adjournment Duration</Rule
><SubCategory
></SubCategory
><Value
>2</Value
></LhcRuleItems
><LhcRuleItems
><Comments
></Comments
><Level
>1</Level
><Id
>1-2BS0UV</Id
><Branch
>Civil</Branch
><Category
></Category
><Rule
>Bench Rules</Rule
><SubCategory
></SubCategory
><Value
>BR</Value
></LhcRuleItems
></ListOfLhcRulesItemsBo
></SiebelMessage
>
I want output like:
<Rules>
<BenchType>Divisional</BenchType>
<CourtFee>1</CourtFee>
</Rules>
I am tying a solution posted in this postLink but it is not working. I am getting output with values only. Current output:
<?xml version="1.0" encoding="UTF-8"?>
<SiebelMessage MessageId="1-2WPBG" IntObjectName="LHC Rules Items IO" MessageType="Integration Object" IntObjectFormat="Siebel Hierarchical">
<ListOfLhcRulesItemsBo>
</ListOfLhcRulesItemsBo>
</SiebelMessage>
Attempted XSLT:
<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="UniqueRecords" match="LhcRuleItems" use="Rule"/>
<xsl:template match="node()|@*" name="FinalRules">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="LhcRuleItems"/>
<xsl:template match="SiebelMessage/ListOfLhcRulesItemsBo/LhcRuleItems">
<xsl:for-each select="Rule">
<xsl:element name="{translate(Rule, ' ' , '')}">
<xsl:value-of select="Value"/>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Updated question with a complete sample xml file. I updated my current XSLT and now I am not getting anything in output.