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

  • Home
  • SEARCH
  • 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 8807401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:21:34+00:00 2026-06-14T02:21:34+00:00

I have an XML with multiple nodes with similar data in each. I want

  • 0

I have an XML with multiple nodes with similar data in each. I want to delete a specific attribute from each node (USER:IPADDRESS). I’ve figured out how to chain together a number of elements using ors, simply leaving out the User=”{@User}” match so it doesn’t show up in the results:

XSL Snippet:

<xsl:template match="Creation | Test | Assignment | Modification | Repair | Termination">
<Creation CommitID="{@CommitID}" Date="{@Date}" BoardID="{@BoardID}">
<xsl:apply-templates/>
</Creation>
</xsl:template>

Unsurprisingly, all of the node names after “Creation” get re-named to Creation because that’s what I’m telling it to do. How do I pass in the various matches so they’re applied in the proper order in the results? I know I can do a brute force way using identical XSL statements for each of the various matches (that’s how I did it the first time), but there must be a more elegant method, it’s just evading me. I have millions & millions of lines of XML to process and this is just the first of many transforms I’m going to have to make.

I’m using msxsl V4.0 on a Win7 box to do my transforms if that’s of any consequence.

XML:

<?xml version="1.0"?>
<BoardDatabase>
<Board_Data BoardID="1035">
    <Creation CommitID="12b" Date="2007-12-07T15:43:51" BoardID="1035" User="CSAGAN:192.168.1.177">
        <BoardDrawing>3B</BoardDrawing>
        <AssemblyDrawing>2010F</AssemblyDrawing>
        <Notes>PO Num 1959</Notes>
    </Creation>
    <Test CommitID="117" Date="2007-12-10T10:39:43" BoardID="1035" User="CSAGAN:192.168.1.183">
        <ElectricalTestData Result="FAIL" Version="IMM STD REVF">
            <AutomatedTest ReportVersion="1.0">
                <TestSetup>
                    <TestAppBuildDate>Dec 07 2007</TestAppBuildDate>
                    <VersionPath>c:\tests\versions\v12.txt</VersionPath>
                    <VersionNumber>1.2</VersionNumber>
                    <OperatorName>CSAGAN</OperatorName>
                    <StationID>PC-191-NDGrasse</StationID>
                    <JigSN>12345</JigSN>
                    <JigAssembly>42</JigAssembly>
                    <TestStartTime>2007-12-10 10:34:17</TestStartTime>
                </TestSetup>
            </AutomatedTest>
        </ElectricalTestData>
    </Test>
    <Assignment CommitID="1c1f" User="JRandi:192.168.1.162" Date="2008-09-30T07:36:52" BoardID="1035">
        <Notes>Boardset failed etest twice, no problem log entry/repair attempts made.</Notes>
    </Assignment>
    <Modification CommitID="2bb7" User="JRandi:192.168.1.162" Date="2009-03-11T13:31:21" BoardID="1035">
        <AssemblyDrawing>2001G</AssemblyDrawing>
        <Notes>Cornelius upgraded boardset to rev. G</Notes>
    </Modification>
</Board_Data>
</BoardDatabase>

XSL:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="Creation | Test | Assignment | Modification | Repair | Termination">
<Creation CommitID="{@CommitID}" Date="{@Date}" BoardID="{@BoardID}">
<xsl:apply-templates/>
</Creation>
</xsl:template>

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

Latest XSL using @DevNull’s solution that doubles size of original file:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<!-- Answer from Stack Overflow that only strips out the IP Address from the User attribute. -->
<xsl:template match="@User">
  <xsl:attribute name="User">
    <xsl:value-of select="substring-before(.,':')"/>
  </xsl:attribute>
</xsl:template>

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

Latest XSL from @Dimitre’s solution that takes a very long time to process (still running after more than 30 minutes, but file is still growing):

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes" indent="yes"/>
  <xsl:strip-space elements="*"/>

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

 <xsl:template match=
  "*[contains('|Creation|Test|Assignment|Modification|Repair|Termination|',concat('|', name(), '|'))
]/@user"/>
</xsl:stylesheet>
  • 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-14T02:21:35+00:00Added an answer on June 14, 2026 at 2:21 am

    Try changing your template to this:

    <xsl:template match="Creation|Test|Assignment|Modification|Repair|Termination">
        <xsl:copy>
            <xsl:apply-templates select="@*[not(name()='User')]|node()"/>
        </xsl:copy>
    </xsl:template>
    

    You’ll notice it looks a lot like your identity template with a predicate added to @*.

    Also, if you wanted to strip all User attributes no matter what the element was, you could use this template instead:

    <xsl:template match="@User"/>
    

    Here’s one more way (only stripping from Creation and Test for brevity)

    <xsl:template match="@User[..[self::Creation or self::Test]]"/>
    

    Answer to comment

    Use this template instead:

    <xsl:template match="@User">
        <xsl:attribute name="User">
            <xsl:value-of select="substring-before(.,':')"/>
        </xsl:attribute>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add an XML node to multiple parent nodes(which have same
I have an xml file with multiple nodes: <member> <screen_name>User</screen_name> <username>username</username> </member> What I
I have an XML valued column that has multiple parent nodes. I need to
I have multiple XML configs. struts.xml <struts> <include file=struts-user.xml /> <package name=baseInterceptors extends=struts-default> <interceptor
I have an XML file (on the left) and I want to create multiple
I have a XML document with my data in it, multiple entries for the
I have xml data(file or text) sent to client from web server. The xml
I have many many XML files that often contain nodes mutiple times (each time
I have an xml document with multiple nodes that looks something like this: <Result>
In a table, I have multiple rows, each containing xml based on common schema.

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.