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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:47:38+00:00 2026-06-18T06:47:38+00:00

I am trying to parse a xml to generate a html report.The problematic section

  • 0

I am trying to parse a xml to generate a html report.The problematic section of the xml is as given

<failure message="Management changes link count is not 3$HiHello" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: Management changes link count is not 3$HiHelloJI
at CustomProjects.CommonTemplates.verifyManagementChanges(Unknown Source)
at CustomProjects.EmersonTest.testEmerson_VerifyManagementChanges(Unknown Source)
</failure>

The xslt written for parsing this is :

<xsl:choose>
        <xsl:when test="failure">
            <td>Failure</td>
            <td><xsl:apply-templates select="failure"/></td>
            <td><a href="ftp://10.32.1.66/seleniumScreenshotsFireFoxTest/{@name}.png" target="_blank">screenshot</a></td>
            <td><xsl:apply-templates select="failurelink"/></td>
        </xsl:when>
</xsl:choose>

<xsl:template match="failure">
  <xsl:call-template name="display-failures"/>
</xsl:template>

<xsl:template match="failurelink">
  <xsl:call-template name="display-failures-link"/>
</xsl:template>

<xsl:template name="display-failures">
  <xsl:param name="FailText" select="@message"/>
    <xsl:choose>
     <xsl:when test="not(@message)">N/A</xsl:when>
    <xsl:otherwise>
       <xsl:value-of select="substring-before($FailText,'$')"/>
    </xsl:otherwise>
</xsl:choose>
<!-- display the stacktrace -->
<code>
    <br/><br/>
    <xsl:call-template name="br-replace">
        <xsl:with-param name="word" select="."/>
    </xsl:call-template>
</code>
<!-- the later is better but might be problematic for non-21" monitors... -->
<!--pre><xsl:value-of select="."/></pre-->
</xsl:template>

<xsl:template name="display-failures-link">
<xsl:param name="linktext" select="@message"/>
 <xsl:choose>
    <xsl:when test="not(@message)">N/A</xsl:when>
    <xsl:otherwise>
       <xsl:value-of select="substring-after($linktext,'$')"/>
    </xsl:otherwise>
</xsl:choose>
<!-- display the stacktrace -->
<code>
    <br/><br/>
    <xsl:call-template name="br-replace">
        <xsl:with-param name="word" select="."/>
    </xsl:call-template>
</code>
<!-- the later is better but might be problematic for non-21" monitors... -->
<!--pre><xsl:value-of select="."/></pre-->
</xsl:template>

Here I am getting the desired result(The String before $ sign) from display-failures template but on calling display-failures-link I am getting nothing.(Should get the string after $ sign).I dont know whether the problem is with sunstring function or with something else.Kindly let me know what I am doing wrong here.

Any help is highly appreciated.

  • 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-18T06:47:40+00:00Added an answer on June 18, 2026 at 6:47 am

    The problem here is that you are trying to apply-templates on the XPath failurelink, but you don’t have an element called <failurelink>, so this apply-templates isn’t finding anything.

    <xsl:apply-templates select="failurelink"/>
    

    One way to apply two different templates on the same kind of element is to use modes:

    <xsl:template match="failure">
      <xsl:call-template name="display-failures"/>
    </xsl:template>
    
    <xsl:template match="failure" mode="link">
      <xsl:call-template name="display-failures-link"/>
    </xsl:template>
    

    Then the area where you apply the templates would change to this:

    <td>Failure</td>
    <td><xsl:apply-templates select="failure"/></td>
    <td><a href="ftp://10.32.1.66/seleniumScreenshotsFireFoxTest/{@name}.png" target="_blank">screenshot</a></td>
    <td><xsl:apply-templates select="failure" mode="link"/></td>
    

    But in your case, there’s an even better approach. Just eliminate the second template, and do this:

    Replace the whole <xsl:choose> with:

    <xsl:apply-templates select="failure" />
    

    Replace the first template you listed with:

    <xsl:template match="failure">
       <td>Failure</td>
       <td><xsl:call-template name="display-failures"/></td>
       <td><a href="ftp://10.32.1.66/seleniumScreenshotsFireFoxTest/{../@name}.png" target="_blank">screenshot</a></td>
       <td><xsl:call-template name="display-failures-link"/></td>
    </xsl:template>
    

    And delete the second template you listed.

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

Sidebar

Related Questions

I'm trying to use append to generate html using data from an xml file.
I am trying to parse XML files using Nokogiri, Ruby and XPath. I usually
I am trying to parse XML with jsoup, but I can't find any examples
I'm trying to parse xml done like this: <foreign lang=gre>&lsquo;<LM lemma=auieo catg=fg>auieo</LM>&rsquo;</foreign> I'm using
Trying to parse some XML but apparently this is too much for a lazy
im trying to parse the XML returned by Google contacts API i made some
I am trying to parse specific XML file which is located in sub directories
I'm trying to parse an XML coming from an php request URI: http://caracasfutbolclub.com/service/news.php .
I'm trying to parse this XML I want to get a list of all
I am trying to parse an XML file with python using lxml, but get

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.