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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:21:32+00:00 2026-06-11T20:21:32+00:00

I have one requierment where i want to remove some tags from xml based

  • 0

I have one requierment where i want to remove some tags from xml based on condition.

Here is my input xml:

<?xml version="1.0" encoding="UTF-8"?>
<TCXML xmlns="http://www.tcxml.org/Schemas/TCXMLSchema">
<File creation_date="2012-09-20T07:28:47Z" elemId="id280" exportedFileName="sheet 1" last_mod_date="2012-09-20T07:28:48Z" text_flag="8192">

    <GSIdentity elemId="id111" label="R0dB1SzBBT4jNA"/>

</File>
  <File creation_date="2012-09-20T07:18:26Z" elemId="id283"exportedFileName="test part" last_mod_date="2012-09-20T07:18:26Z"  text_flag="8192">

    <GSIdentity elemId="id31" label="SIWBFqLyBT4jNA"/>

</File>
  <File creation_date="2012-09-20T07:21:03Z" elemId="id322" exportedFileName="test part3"  last_mod_date="2012-09-20T07:21:03Z"  text_flag="8192">

    <GSIdentity elemId="id46" label="ycUBFqLyBT4jNA"/>

</File>
  <File creation_date="2012-09-20T07:18:25Z" elemId="id285" exportedFileName="test part2"  last_mod_date="2012-09-20T07:18:25Z"  text_flag="4096">

    <GSIdentity elemId="id29" label="SQRBFqLyBT4jNA"/>

</File>

  <Sheet creation_date="2012-09-20T07:28:48Z" date_released="" ead_paragraph="" elemId="id185"  keep_limit_prop="3" last_mod_date="2012-09-20T07:28:48Z"  object_desc="" object_name="Sheet 1"  ref_list="#id111">

    <GSIdentity elemId="id112" label="R4WB1SzBBT4jNA"/>

</Sheet>


  <PART creation_date="2012-09-20T07:21:22Z" date_released="" ead_paragraph="" elemId="id435"  keep_limit_prop="3" last_mod_date="2012-09-20T07:21:28Z" object_name="dwgTest-AA-dwg1" ref_list="#id29 #id31">

    <GSIdentity elemId="id32" label="SxZBFqLyBT4jNA"/>

</PART>
  <PART creation_date="2012-09-20T07:21:23Z" date_released="2012-09-20T07:21:27Z" ead_paragraph="" elemId="id438"  keep_limit_prop="3" last_mod_date="2012-09-20T07:21:29Z"  object_name="dwgTest-AA-dwg2" ref_list="#id46">

    <GSIdentity elemId="id21" label="itfBFqLyBT4jNA"/>

</PART>
</TCXML>

I want to remove those File tags from this xml which are referred in PART with ref_list tags.

I am trying with following xsl,

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:plm="http://www.tcxml.org/Schemas/TCXMLSchema" version="1.0">
  <xsl:output method="xml" indent="yes"/>

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

<xsl:template match="plm:File">

    <xsl:variable name="Ref_List" select="translate(/plm:TCXML/plm:PART/@ref_list,' ','')" />
    <xsl:variable name="currentElementGSId" select="plm:GSIdentity/@elemId" />  
    <xsl:variable name="RefcurrentElementGSId" select="concat(string('#'),$currentElementGSId)" />  
    <xsl:choose>
        <xsl:when test="((contains($Ref_List,$RefcurrentElementGSId))=true())" >
            </xsl:when>
    <xsl:otherwise>
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" /> 
        </xsl:copy>         
    </xsl:otherwise>
    </xsl:choose>   
</xsl:template>

Above xsl is working only for one PART in the xml and not all PART tags from the xml , how to loop through all PART tags in the xml.
Thanks for your help in advance.

I am looking for output for this xml as follows,

<?xml version="1.0" encoding="UTF-8"?>
<TCXML xmlns="http://www.tcxml.org/Schemas/TCXMLSchema">
<File creation_date="2012-09-20T07:28:47Z" elemId="id280" exportedFileName="sheet 1" last_mod_date="2012-09-20T07:28:48Z" text_flag="8192">

    <GSIdentity elemId="id111" label="R0dB1SzBBT4jNA"/>

</File>

  <Sheet creation_date="2012-09-20T07:28:48Z" date_released="" ead_paragraph="" elemId="id185"  keep_limit_prop="3" last_mod_date="2012-09-20T07:28:48Z"  object_desc="" object_name="Sheet 1"  ref_list="#id111">

    <GSIdentity elemId="id112" label="R4WB1SzBBT4jNA"/>

</Sheet>


  <PART creation_date="2012-09-20T07:21:22Z" date_released="" ead_paragraph="" elemId="id435"  keep_limit_prop="3" last_mod_date="2012-09-20T07:21:28Z" object_name="dwgTest-AA-dwg1" ref_list="#id29 #id31">

    <GSIdentity elemId="id32" label="SxZBFqLyBT4jNA"/>

</PART>
  <PART creation_date="2012-09-20T07:21:23Z" date_released="2012-09-20T07:21:27Z" ead_paragraph="" elemId="id438"  keep_limit_prop="3" last_mod_date="2012-09-20T07:21:29Z"  object_name="dwgTest-AA-dwg2" ref_list="#id46">

    <GSIdentity elemId="id21" label="itfBFqLyBT4jNA"/>

</PART>
</TCXML>
  • 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-06-11T20:21:33+00:00Added an answer on June 11, 2026 at 8:21 pm

    Your input/output do not match your description:

    I want to remove those File tags from this xml which are referred in
    PART with ref_list tags.

    The following XSLT performs an operation equal to that description:

    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:plm="http://www.tcxml.org/Schemas/TCXMLSchema" version="1.0">
        <xsl:output method="xml" indent="yes" />
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()" />
            </xsl:copy>
        </xsl:template>
        <xsl:template match="plm:File">
            <xsl:choose>
                <xsl:when test="/plm:TCXML/plm:PART[contains(
                    concat(' ', @ref_list, ' '), 
                    concat(' #', current()/@elemId, ' '))]">
                </xsl:when>
                <xsl:otherwise>
                    <xsl:copy>
                        <xsl:apply-templates select="@*|node()" />
                    </xsl:copy>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
    </xsl:stylesheet>
    

    The second template discards any File element whose elemId is found in the ref_list attribute of any PART element. All other File elements are copied as-is.

    Note: Your template failed to work as desired because translate expects its first argument to be a string; you passed a node list, which was converted to a string according to the following rule:

    A node-set is converted to a string by returning the string-value of
    the node in the node-set that is first in document order. If the
    node-set is empty, an empty string is returned.

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

Sidebar

Related Questions

i have one database, and it contains some columns. My requirement is that how
I have a requirement where I have to drop one row from a table
I have a requirement to pass credentials from one Microsoft .NET Web Application to
I have one huge XML document. I have set of XSL representing each node
I have some legacy XML documents stored in a database as a blob, which
I have one requirement that I want to create a pool of 5 threads
I have one requirement in C. char abc[]=hello; char hello[]=world; Using abc whether we
I have one requirement that i have to place the log file in the
I am developing native iPhone app. I have one requirement that, there are 5
I have one intresting requirement to achieve. could you please help? Please find the

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.