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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:50:30+00:00 2026-05-24T16:50:30+00:00

I need rename all nodes <‘record> in <‘array>. The name should be the same

  • 0

I need rename all nodes <‘record> in <‘array>. The name should be the same as the name of its array. Then move <‘record> +1 up. And finally remove array.

This is my xml:

<IDataXMLCoder version="1.0">
  <record javaclass="xxx">
    <value name="errorCode">0</value>
    <array name="service" type="record" depth="1">
      <record javaclass="xxx">
        <value name="serviceName">PT</value>
        <value name="serviceId">99</value>
        <value name="serviceInternalId">8</value>
        <value name="packageSymbol">8888</value>
        <value name="serviceComment">RT</value>
        <value name="serviceNameInChannel">RT</value>
        <value name="serviceActivationParam">NOW</value>
        <value name="serviceDeactivationParam">NOW</value>
        <null name="estimatedProcessingTime"/>
        <null name="virtualService"/>
      </record>
      <record javaclass="zzz">
        <value name="serviceName">RK</value>
...

This should looks like:

<?xml version="1.0" encoding="UTF-8"?><IDataXMLCoder>
  <record>
    <errorCode>0</errorCode>
    <service>
      <serviceName>PT</serviceName>
      <serviceId>99</serviceId>
      <serviceInternalId>8</serviceInternalId>
      <packageSymbol>8888</packageSymbol>
      <serviceComment>RT</serviceComment>
      <serviceNameInChannel>RT</serviceNameInChannel>
      <serviceActivationParam>NOW</serviceActivationParam>
      <serviceDeactivationParam>NOW</serviceDeactivationParam>
      <estimatedProcessingTime/>
      <virtualService/>
    </service>
    <service>
      <serviceName>RK</serviceName>
...

Here is my code:

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

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

    <!--change record's name to service-->
    <xsl:template match="array/record">
        <xsl:element name="service">
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:template>

    <!--node name as attribute's name-->
    <xsl:template match="*[@name]">
        <xsl:element name="{@name}">
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:template>


</xsl:stylesheet>

Now i see nodes <‘record> as <‘service> but i don;t know how move up and delete the array.

  • 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-24T16:50:31+00:00Added an answer on May 24, 2026 at 4:50 pm

    Your problem is that your <array name="service"..> element is being processed by your last template, and is adding in an extra <service> element. Just add this template to remove it:

    <xsl:template match="array[@type='service']">
      <xsl:apply-templates />
    </xsl:template>
    

    This will override the more specific match="*[@name]" template match when placed after it.

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

Sidebar

Related Questions

I need to monitor a folder and its subdirectories for any file manipulations (add/remove/rename).
I need to rename it and that should reflect in all the dependency objects.
I need to rename all of my tables, stored procedures and obviously the code
Using Oracle 10g, I need to rename a bunch of FK constraints which all
I need to rename all the images as the title explains in all sub-folders.
I create a Jtree that all of its nodes have User object, I fill
I need to rename all of the files in a folder with the following
I need to rename a constraint in an Oracle databse, but I don't know
I just need to rename JQgrid column dynamically as per user selection from a
I have a file I need to rename to that of an existing file.

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.