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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:18:50+00:00 2026-05-18T23:18:50+00:00

I’ve got this issue. A template called checkbox that’s called from while inside a

  • 0

I’ve got this issue.

A template called “checkbox” that’s called from while inside a table HTML element and also outside of it.

To solve an issue, I’ve added <td> tags to “checkbox” input control.

Here’s what I’d like to do to but I’m not sure if it’s possible or not.

When I hit my “row” (part of the custom table markup) template, I would set some variable or pass some parameter, that for each template applied afterwards, would know it was in a “row” and do something special based on this information. I know I can’t add parameters to apply-templates. I may be able to add a row “mode” but I can’t make changes to each template and have one copy with the mod parameter and one without.

Thanks for any suggestions. I know the ideal solution would to be to make changes to the XML but I’m not sure if I can do that as this point. That’s a “content” issue. 😛

Thanks!

Addendum:

I’m going to try to better explain my issue.

I have this template called “checkbox”. Sometimes I need a tag surrounding the call that renders the checkbox, sometimes I do not. The times I do the “checkbox” template are when its parents are called by a “row” template’s call to apply-templates (this translates to a , thus the need for the for the checkbox forum control).

The problem is I need to be able to reuse the checkbox template in both cases: 1) When it’s not being called by a row template and when it IS being called by a row template.

I hope this is clearer.

  • 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-18T23:18:51+00:00Added an answer on May 18, 2026 at 11:18 pm

    When I hit my “row” (part of the
    custom table markup) template, I would
    set some variable or pass some
    parameter, that for each template
    applied afterwards, would know it was
    in a “row” and do something special
    based on this information. I know I
    can’t add parameters to
    apply-templates. I may be able to add
    a row “mode” but I can’t make changes
    to each template and have one copy
    with the mod parameter and one
    without.

    To begin with, parameters can be passed to templates that are selected for processing by an <xsl:apply-templates> instruction. Do read about <xsl:with-param>.

    However, passing such a parameter isn’t usually needed. Here is an example:

    If a template matches a specific (current) node and it must act in a special way depending whether this node is within a table row, then it is a matter of a simple check:

    parent::tr

    selects the parent node only if it is a tr.

    ancestor::tr

    selects all ancestor tr nodes.

    In case the first or the second XPath expressions above selects a non-empty node-set, then (respectively), the parent of the current node is a tr, or the current node is within some tr.

    So, you may use an <xsl:when> to test this.

    Here is how a complete solution may look like:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="checkbox">
      <xsl:choose>
       <xsl:when test="ancestor::tr">
         <myTag><xsl:copy-of select="."/></myTag>
       </xsl:when>
       <xsl:otherwise>
        <xsl:copy-of select="."/>
       </xsl:otherwise>
      </xsl:choose>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the following XML document:

    <t>
      <checkbox>1</checkbox>
      <table>
        <tr>
          <td><checkbox>1</checkbox></td>
        </tr>
      </table>
    </t>
    

    the wanted, correct result is produced:

    <checkbox>1</checkbox>
    <myTag>
       <checkbox>1</checkbox>
    </myTag>
    

    Very often conditional instructions can be completely eliminated by specifying specific templates with predicates in the match pattern. If you provide the necessary relevant information, people might be able to publish an elegant solution.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
i got an object with contents of html markup in it, for example: string
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

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.