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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:51:19+00:00 2026-05-30T11:51:19+00:00

this is not my code. but it similer to what i want thats why

  • 0

this is not my code. but it similer to what i want thats why i am using it here. i got this from here

<xsl:template match="/">
<xsl:apply-templates select="event/details">
<xsl:with-param name="title" select="event/title"/> <!-- pass param "title" to matching templates -->
</xsl:apply-templates>
</xsl:template>

<xsl:template match="details">
<xsl:param name="title"/> <!-- this template takes parameter "title" -->
Title: <xsl:value-of select="$title"/><br/>
Timestamp: <xsl:value-of select="java:DateUtil.getDate(number(timestamp))"/><br/>
Description: <xsl:value-of select="description"/><br/>
</xsl:template>

My issue is can i have above match template “details” with parameter and one without parameter? sorry for my english..let me know if i dont make sense i will try my best to reword this. thank you in advanced.

EDIT : here is what i want.

template 1 - with parameter:

<xsl:template match="details">
<xsl:param name="title"/> <!-- this template takes parameter "title" -->
Title: <xsl:value-of select="$title"/><br/>
Timestamp: <xsl:value-of select="java:DateUtil.getDate(number(timestamp))"/><br/>
Description: <xsl:value-of select="description"/><br/>
</xsl:template>

template 2 - without parameter:

<xsl:template match="/">
<xsl:apply-templates select="event/details"/>
</xsl:template>

<xsl:template match="details">
Timestamp: <xsl:value-of select="java:DateUtil.getDate(number(timestamp))"/><br/>
Description: <xsl:value-of select="description"/><br/>
</xsl:template>
  • 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-30T11:51:20+00:00Added an answer on May 30, 2026 at 11:51 am

    I. It is a recoverable error to have two templates with the same match pattern — in the best cases only one of these will be selected for execution.

    In your specific example, you can use just the template with the parameter and slightly modify its code so that when the parameter has no value (the empty string), then no title is written.

    Here is a small demonstration how this can be done:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
        <xsl:template match="/">
            <xsl:apply-templates select="event/details"/>
            ===========
            <xsl:apply-templates select="event/details">
              <xsl:with-param name="title" select="'Title Provided'"/>
            </xsl:apply-templates>
    
        </xsl:template>
    
        <xsl:template match="details">
            <xsl:param name="title"/>
    
        <xsl:value-of select=
        "concat(substring('Title: ',
                          1 + 7*not(string-length($title) > 0)
                          ),
                $title)
        "/>
            <br/> Timestamp: 
            <xsl:value-of select="'someTimeStamp'"/>
            <br/> Description: 
            <xsl:value-of select="description"/>
            <br/>
        </xsl:template>
    
    </xsl:stylesheet>
    

    In this transformation the template matching details is invoked twice — the first time without a parameter and the second time with a $title parameter. In both cases the template produces the wanted output:

    <br/> Timestamp: 
            someTimeStamp<br/> Description: 
            <br/>
            ===========
            Title: Title Provided<br/> Timestamp: 
            someTimeStamp<br/> Description: 
            <br/>
    

    II. xsl:function in XSLT 2.0

    What you want can be achieved with xsl:function — functions written in XSLT — this feature is available only in XSLT 2.0 (and up). It is perfectly possible to write different overloads of the same function and we have many examples of this.

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

Sidebar

Related Questions

Got this line of code here but its not working. private void Button_Click(object sender,
Hey. I know this is not a 'refactor my code' site but I made
runat=server /> But this code is not working How can I add multiple controls
I usually do not have difficulty to read JavaScript code but for this one
This code does not throw an error but the query fails, that is, the
I've seen several examples of code like this: if not someobj: #do something But
This javascript code does not work in IE8, but works in Firefox and Google
I know this sort of code is not best practice, but nevertheless in certain
I tried this, but could not get through:- code behind protected HtmlTableRow trComment; protected
How can I do this? (The following code does NOT work, but I hope

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.