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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:00:51+00:00 2026-06-06T15:00:51+00:00

This is my input xml. The xml can have maximunm three nodes and minimum

  • 0

This is my input xml. The xml can have maximunm three nodes and minimum 1 node. The minimum nodes, the input xml can have, like below

<Root>
   <node>uniquename</node>
</Root>

The maximum nodes, the input xml can have is below. Uniquename containing node will be there always.

my sample input xml for the below sample desired output

<Root>
   <node>abc</node>
   <node>e1</node>
   <node>uniquename2</node>
</Root>

The value ‘abc’ is common for all the input xmls. the value e1, is like a version number. It can have e1 through e9. It can also have a minor version like e1.1 through e9.9. The third node is unique. My output should be the text below, sample below as desired output

Unique name with version from the xml - uniquename2e1
version number - e1
common name - Present in the input

The order of the input xml nodes varies, ie sometimes the version number can come at the top and sometimes the unique name can come at the top. Same is true with the common name. Nevertheless my output should have uniquename followed by version number. In case there is no common name in the input xml, the output text should indicate, it is absent

If the version number is not there in the input, the version number line can be blank from the output

Unique name with version from the xml - uniquename3
common name - Present/Absent in the input.

Though I dont have xslt 2.0 processor, my xslt processor supports xmlns:regexp=”http://exslt.org/regular-expressions&#8221;, I was thinking to use this for finding the versioning part.

EDIT

The unique name is something which is not following the version number pattern ^e\d(\.\d)*$ or not the common name

  • 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-06T15:00:52+00:00Added an answer on June 6, 2026 at 3:00 pm

    This XSLT 1.0 transformation:

    <xsl:stylesheet version="1.0"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns:my="my:my">
         <xsl:output method="text"/>
    
         <my:commonAbsent/>
    
         <xsl:variable name="vVer" select=
          "/*/node
               [starts-with(., 'e')
              and
               number(substring(.,2)) = number(substring(.,2))]"/>
    
         <xsl:template match="/*">
          <xsl:apply-templates mode="unique" select=
           "node[not(. = 'abc'
                    or
                     generate-id() =generate-id($vVer)
                     )
                 ]"/>
          <xsl:apply-templates select="$vVer" mode="ver"/>
    
          <xsl:apply-templates select=
           "node[. = 'abc']
           |
            document('')
               [not(current()/node[.='abc'])]
                            /*/my:commonAbsent
           "/>
         </xsl:template>
    
         <xsl:template match="node" mode="unique">
         Unique name with version from the xml - <xsl:text/>
    
         <xsl:value-of select="concat(., $vVer)"/>
         </xsl:template>
    
         <xsl:template match="node" mode="ver">
         Version number - <xsl:value-of select="$vVer"/>
         </xsl:template>
    
         <xsl:template match="node[. = 'abc']">
         Common name - Present in the input
         </xsl:template>
    
         <xsl:template match="my:commonAbsent">
         Common name - Absent in the input
         </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <Root>
        <node>abc</node>
        <node>e1</node>
        <node>uniquename2</node>
    </Root>
    

    produces the wanted, correct result:

     Unique name with version from the xml - uniquename2e1
     Version number - e1
     Common name - Present in the input
    

    When the same transformation is applied on an XML document that has no “common name”:

    <Root>
        <node>e1</node>
        <node>uniquename2</node>
    </Root>
    

    again the correct, wanted result is produced:

     Unique name with version from the xml - uniquename2e1
     Version number - e1
     Common name - Absent in the input
    

    Finally, if the “version” is not represented in the XML document:

    <Root>
        <node>abc</node>
        <node>uniquename2</node>
    </Root>
    

    applying the same transformation again produces the wanted, correct result:

     Unique name with version from the xml - uniquename2
     Common name - Present in the input
    

    Explanation:

    The order of the nodes in the result tree (in these case all of them are text nodes) is determined completely by the order of the xsl:apply-templates instructions that select for execution the templates that produce these result-tree nodes.

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

Sidebar

Related Questions

I have this use case of an xml file with input like Input: <abc
I have a stored proc that takes an input of xml value like this:
This is my input xml: <root> <node1/> <node2/> <node3/> <node4/> <othertags/> </root> The output
The input XML tag must be validated for a pattern which is like this:
I have the following XML <ns0:Root xmlns:ns0=http://Map_Sample.Input_Schema> <Number1> </Number1> <Number2>11</Number2> <Number3>12</Number3> </ns0:Root> In this
I have a XML input which is obtained dynamically.How can i write the style
Can someone please help me out with this scenario asap? Input XML: <dataXML> <Items>
I have xml input which looks like (simplified version used for example): <Student> <Subject>
I have a query in the xml and xslt The below is the Input
I have an XML input as shown below: <?xml version=1.0 encoding=utf-8?> <Content> <section name=FileID/>

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.