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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:18:51+00:00 2026-05-25T02:18:51+00:00

The following is the sample XML structure I’m working on: <command name=test> <parameter index=2>4000</parameter>

  • 0

The following is the sample XML structure I’m working on:

<command name="test">
      <parameter index="2">4000</parameter>
      <tag>4000</tag>
      <parameter index="3">tag</parameter>
      <parameter index="4">4000</parameter>
    </command>

<command name="test">
  <parameter index="2">4000</parameter>
  <add>
    <parameter index="1">ports</parameter>
    <parameter index="2">1:1,</parameter>
    <parameter index="3">3:1,</parameter>
    <parameter index="4">3:9-12,</parameter>
    <parameter index="5">4:12</parameter>
  </add>
  <parameter index="3">add</parameter>
  <parameter index="4">ports</parameter>
  <parameter index="5">1:1,</parameter>
  <parameter index="6">3:1,</parameter>
  <parameter index="7">3:9-12,</parameter>
  <parameter index="8">4:12</parameter>
  <tagged />
  <parameter index="9">tagged</parameter>
</command>

And the code snippet on the XSL file is:

 <xsl:key name="key" match="command[@name='test'][count(tag) &gt; 0]" use="parameter[@index='2']"/>
    <xsl:key name="port" match="command[@name='test'][count(add) &gt; 0]" use="add/parameter"/>

<xsl:template match="xyz">
<xsl:variable name="portid" select="concat($slot-no,concat(':',$port-no))"/>
<xsl:apply-templates select="key('port',$portid)"/>
</xsl:template>

<xsl:template match="command[@name='test']">
         <xsl:variable name="name" select="parameter[@index=2]"/>
         <object>
         <name><xsl:value-of select="$name"/></name>
                  <class>XYZ</class>
            <attributes>
               <attribute>
                  <name>XYZ1</name>
                  <value><xsl:value-of select="key('key',$name)/tag"/></value>
               </attribute>
            </attributes>
         </object>
</xsl:template>

The variable ‘portid’ is in the form ‘x:x’, where x is a number. For each of the portid, I need to associate with the <parameter index="2"> value. Previously we had only one portid value under the <add> node and the solution was working fine.

Now, I need to change the ‘use’ expression in the XSL key ‘port’ so that the values are changed from ‘1:1,’ to ‘1:1’ and similarly ‘3:1,’ to ‘3:1’ and expand ‘3:9-12,’ to ‘3:9’ , ‘3:10’ , ‘3:11’ , ‘3:12’ and store them with the value in <parameter index="2">. For example, each time the ‘portid’ is any one of this ‘1:1’, ‘3:1’, ‘3:9’ , ‘3:10’ , ‘3:11’, ‘3:12’ and ‘4:12’, the value to associate is ‘4000’.

Is this possible? I’m working on this for a week and still not able to find a solution. Any help would be really appreciated. Thanks a lot guys.

  • 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-25T02:18:51+00:00Added an answer on May 25, 2026 at 2:18 am

    I was able to find the solution for this problem by not using the XSL key. Instead I used a call-template method to strip the commas and expand the series and find the match. Thanks to all who cared to help me on this

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

Sidebar

Related Questions

I've an xml file (Sample.xml) which has the following structure <RootElement> <Children> <Child Name=FirstChild
I've an xml file (Sample.xml) which has the following structure <RootElement> <Child Name=FirstChild Start=1
I have the following sample XML structure: <SavingAccounts> <SavingAccount> <ServiceOnline>yes</ServiceOnline> <ServiceViaPhone>no</ServiceViaPhone> </SavingAccount> <SavingAccount> <ServiceOnline>no</ServiceOnline>
I've an xml file(Sample.xml) which has the following structure <Root> <Child ChildName=Ms_7> <MissingSiblings> <Sibling
I have a sample htm file with following structure and it POSTs the xml
i have the following xml structure and want to add it to a treeview.
I have a large xml file (approx. 10 MB) in following simple structure: <Errors>
I have the following sample data: Id Name Quantity 1 Red 1 2 Red
The XML file have the following structure <RootElement> <TestElement Count=10/> </RootElement> I need to
I want to unmarshall the following XML structure using JAXB: <orCondition> <andCondition> <andCondition> <simpleCondition

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.