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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:48:15+00:00 2026-05-27T04:48:15+00:00

Advance thanks for those who will reply bcoz i google it lot but no

  • 0

Advance thanks for those who will reply bcoz i google it lot but no luck & i am also new in XSL.
Provided XML

<Parameterdef>
<Anode>
    <Anodeid>1</Anodeid>
</Anode>
<Bnode>
    <Bnodeid>2</Bnodeid>
</Bnode>
<ParameterVisualization>
    <ParameterDefinition>
        <ParameterSection>Anode</ParameterSection>
        <Parameter>Anodeid</Parameter>
    </ParameterDefinition>
    <ParameterDefinition>
        <ParameterSection>Bnode</ParameterSection>
        <Parameter>Bnodeid</Parameter> 
    </ParameterDefinition>
    <ParameterDefinition>
        <ParameterSection>Cnode</ParameterSection>
        <Parameter>Cnodeid</Parameter> 
    </ParameterDefinition>
</ParameterVisualization>
</Parameterdef>

Depends on node value i have to parse hole xml and needs to get the value of that node if that node is exist.

Require OutPut:
1,2,N/A(because Cnode is not defined)

  • 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-27T04:48:15+00:00Added an answer on May 27, 2026 at 4:48 am

    XPath functions name() and local-name() can be used to read the name of an unknown element. These are then compared to element values in a predicate. I’m assuming that the line </MLinkParameterDefinition> in your sample code was a typing error and </ParameterDefinition> was meant instead. In this solution both <ParameterSection> and <Parameter> must have a value that matches an element, it also checks that the value of the id-elements must be non-empty.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:template match="/">
        <xsl:apply-templates select="*/ParameterVisualization/ParameterDefinition"/>
    </xsl:template>
    
    <xsl:template match="ParameterDefinition">
        <xsl:variable name="nodeId" select="/*/*[local-name() = current()/ParameterSection]
                                                /*[local-name() = current()/Parameter]
                                                  [normalize-space()]"/>
            <xsl:choose>
                <xsl:when test="$nodeId">
                    <xsl:value-of select="$nodeId"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>N/A</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="following-sibling::ParameterDefinition">
                <xsl:text>,</xsl:text>
            </xsl:if>
    </xsl:template>
    
    </xsl:stylesheet>
    

    Output with your (fixed) sample input

    1,2,N/A
    

    No space between commas and no comma after last value.

    Somehow I feel like keys should be used in these kind of matching problems, but for me this seemed a more straightforward way to solve the problem.

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

Sidebar

Related Questions

Thanks in advance those who view my question. i am new to programming and
Thanks in advance for helping me out (for those who have time and are
Thanks in advance to anyone who can think of a more efficient or a
Sorry in advance for those who find that my title is not precise enough.
Hi thanks in advance for your help. I'm just getting started learning Python and
Special thanks in advance for sending me answer........ I m the beginner in iphone
Thanks in advance for your help. I have a need within an application to
thanks in advance for looking at this. Essentially, I'm calling didInsertElement() and binding an
Thanks in advance for your assistance. I have the following exported part: [Export (typeof(INewComponent))]
Thanks in advance for any help you can provide on this issue! I manage

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.