How to use copy-of and exclude some elements in a way to get the following output

Hi,
ITaggedItem can be used for match.
like match="ITaggedItem" this is common in all.
The interested node to copy is IObject excluded the attribute longtext.
and
<Rel>
    <IRel UID1="c299ab5406de"
    UID2="TAG_13-003" DefUID="TagClassification" />
    <IObject UID="TAG_13-003" />
  </Rel>
Can be used in condition @DefUID="TagClassification.
in addition to that adding new element and attribute.
<User abc="value1">.

If something is not clear please let me know.
thanks
Input
<Container>
<SPXTagTelecom>
  <ITagTelecom />
  <ITaggedItem SerialNo="1234567890" UTCNumber="" />
  <IObject UID="a929496b"  Description="" LongText="LongText" Name="13 DF-00023B" />
    <IQualityLevel QualityLevelContractor="10" />
  <Rel>
    <IRel UID1="c299ab5406de"
    UID2="TAG_13-003" DefUID="TagClassification" />
    <IObject UID="TAG_13-003" />
  </Rel>
   <Rel>
      <IRel UID1="PL_TRAIN" UID2="c299ab5406de" DefUID="PlantTag" />
      <IObject UID="PL_TRAIN.PlantTag.c299ab5406de" />
    </Rel>
  </SPXTagTelecom>
  
<SPXTagABC>
  <ITagTelecom />
  <ITaggedItem SerialNo="1234567890" UTCNumber="" />
  <IObject UID="-c299ab5406de"  Description="" LongText="LongText" Name="13 DF-00023B" />
    <IQualityLevel QualityLevelContractor="10" />
  <Rel>
    <IRel UID1="c299ab5406de"
    UID2="TAG_13-003" DefUID="TagClassification" />
    <IObject UID="TAG_13-003" />
  </Rel>
   <Rel>
      <IRel UID1="PL_TRAIN" UID2="c299ab5406de" DefUID="PlantTag" />
      <IObject UID="PL_TRAIN.PlantTag.c299ab5406de" />
    </Rel>
</SPXTagABC>

</Container>

Output
<Container>
<SPXTagTelecom>
<User abc="value1">
  <IObject UID="a929496b" Name="13 DF-00023B" />
  <Rel>
    <IRel UID1="c299ab5406de"
    UID2="TAG_13-003" DefUID="TagClassification" />
    <IObject UID="TAG_13-003" />
  </Rel>
   <Rel>
      <IRel UID1="PL_TRAIN" UID2="c299ab5406de" DefUID="PlantTag" />
      <IObject UID="PL_TRAIN.PlantTag.c299ab5406de" />
    </Rel>
  </SPXTagTelecom>
  
<SPXTagABC>
<User abc="value1">
  <IObject UID="-c299ab5406de"  Name="13 DF-00023B" />  
  <Rel>
    <IRel UID1="c299ab5406de"
    UID2="TAG_13-003" DefUID="TagClassification" />
    <IObject UID="TAG_13-003" />
  </Rel>
</SPXTagABC>
</Container>

Open in new window

SANbuddiesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert SchuttSoftware EngineerCommented:
Here's a first attempt, I'm sure it's not what you want, but maybe it can be a first step that you can use to explain what needs to be added.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" indent="yes" />

<xsl:template match="@*|node()">
   <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
</xsl:template>

<xsl:template match="IObject">
	<User abc="value1"/>
	<IObject><xsl:copy-of select="@*"/></IObject>
	<xsl:apply-templates select="*" />  
</xsl:template>

<xsl:template match="ITagTelecom|ITaggedItem|IQualityLevel"/>

</xsl:stylesheet>

Open in new window

0
SANbuddiesAuthor Commented:
Thanks for your reply I manage to complete it by using the attached code
<xsl:template match="Container">       
      <xsl:copy> <!--Copy container-->
      <!--<xsl:apply-templates select="node()" />-->
      <xsl:apply-templates select="*[ITaggedItem]" />      
     </xsl:copy>
    </xsl:template>

  <xsl:template match="*[ITaggedItem]">
    <xsl:copy>
      <xsl:apply-templates select="IObject"/>
      <xsl:apply-templates select="Rel"/>
      <xsl:call-template name="FeedBack">
        </xsl:call-template>
    </xsl:copy>       
   </xsl:template>
  
  <xsl:template match="IObject">
    <xsl:copy>
      <xsl:copy-of select="@*[(local-name() = 'UID') or (local-name() = 'Name')]"/>
    </xsl:copy>    
  </xsl:template>

  <xsl:template match="Rel">
    <xsl:if test="IRel/@DefUID='TagClassification'">
      <xsl:copy>
        <xsl:copy-of select="@*|node()"/>
      </xsl:copy>
    </xsl:if>        
  </xsl:template>
  
  <xsl:template name="FeedBack" >
    <ISAPGeneral SAPABCIndicator="VTL_Feedback"/>
  </xsl:template>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SANbuddiesAuthor Commented:
I manage to find the solution myself without getting any answer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.