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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:12:44+00:00 2026-05-16T12:12:44+00:00

Dimitre – great stuff! You nailed the xml schema and my expected result. I

  • 0

Dimitre – great stuff! You nailed the xml schema and my expected result.

I am using a xslt fragment to pull this information into the page. I am passing my pageIds into the xslt via the xslt fragment call. How can extend this code be able to process those passed in parameters in order to display the correct data from the xml?

This is a fragment example.

<%    
    Dim mm_xsl20 As MM.XSLTransform = New MM.XSLTransform()
    mm_xsl20.setXML(Server.MapPath("/" & countryVar & "/" & langVar & "/titles.xml"))
    mm_xsl20.setXSL(Server.MapPath("/data/xslt/breadcrumb.xsl"))
    mm_xsl20.addParameter("pageID1", "hpPage")
    mm_xsl20.addParameter("pageID1_char", "true")
    mm_xsl20.addParameter("pageID2", "homePage")
    mm_xsl20.addParameter("pageID2_char", "true")    
    Response.Write(mm_xsl20.Transform())
%>

#

I am feeding breadcrumbs into a page via xml and a xslt fragment. My problem is that my xslt is looped through and the div breadcrumbtrail is repeated How do I place that in the xslt so that the div breadcrumbtrail is only shown once and all of the if items are contained in it?

Thanks

<xsl:template match="/pageInfo/page">
   <div id="breadcrumbtrail">
       <xsl:if test="name[. = $pageID1]">
          <a href="{url}"><xsl:value-of select="breadCrumbName"/></a>         
          <xsl:if test="$pageID1_char = 'true'">&#62;</xsl:if>
       </xsl:if>
       <xsl:if test="name[. = $pageID2]">
         <a href="{url}"><xsl:value-of select="breadCrumbName"/></a>
         <xsl:if test="$pageID2_char = 'true'">&#62;</xsl:if>
       </xsl:if>
       <xsl:if test="name[. = $pageID3]">
          <a href="{url}"><xsl:value-of select="breadCrumbName"/></a>
          <xsl:if test="$pageID3_char = 'true'">&#62;</xsl:if>
         </xsl:if>
       <xsl:if test="name[. = $pageID4]">
          <a href="{url}"><xsl:value-of select="breadCrumbName"/></a> 
      </xsl:if>
    </div>
</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-16T12:12:45+00:00Added an answer on May 16, 2026 at 12:12 pm

    My problem is that my xslt is looped
    through and the div breadcrumbtrail is
    repeated How do I place that in the
    xslt so that the div breadcrumbtrail
    is only shown once and all of the if
    items are contained in it?

    Here is what I consider a good way to do this:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:meta="my:metadata" exclude-result-prefixes="meta">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
      <meta:pageIds>
       <page pid="p1"/>
       <page pid="p2"/>
       <page pid="p3"/>
       <page pid="p4"/>
     </meta:pageIds>
    
     <xsl:template match="/*">
      <div id="breadcrumbtrail">
       <xsl:apply-templates/>
      </div>
     </xsl:template>
    
     <xsl:template match="page[name=document('')/*/meta:pageIds/page/@pid]">
      <a href="{url}">
       <xsl:apply-templates select="breadCrumbName"/>
      </a>
      <xsl:if test=
       "document('')/*/meta:pageIds/page
                                  [not(position()
                                      =
                                       last()
                                       )
                                   ]
                                    /@pid=current()/name">
       <xsl:text>&#62;</xsl:text>
      </xsl:if>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the following XML document:

    <pageInfo>
     <page>
      <name>p1</name>
      <url>http://myUrl.com/p1/</url>
      <breadCrumbName>News</breadCrumbName>
     </page>
     <page>
      <name>p2</name>
      <url>http://myUrl.com/p2/</url>
      <breadCrumbName>International</breadCrumbName>
     </page>
     <page>
      <name>p3</name>
      <url>http://myUrl.com/p3/</url>
      <breadCrumbName>Europe</breadCrumbName>
     </page>
     <page>
      <name>p4</name>
      <url>http://myUrl.com/p4/</url>
      <breadCrumbName>France</breadCrumbName>
     </page>
    </pageInfo>
    

    the wanted, correct result is produced:

    <div id="breadcrumbtrail">
        <a href="http://myUrl.com/p1/">News</a>&gt;
        <a href="http://myUrl.com/p2/">International</a>&gt;
        <a href="http://myUrl.com/p3/">Europe</a>&gt;
        <a href="http://myUrl.com/p4/">France</a>
    </div>
    

    Do note:

    1. Most of the conditional logic in your code is unnecessary and is eliminated in this solution.

    2. The list of pages that participate in forming the breadcrumb can be easily modified/extended without requiring any changes in the code.

    3. The globally-defined element <meta:pageIds> is best put in its separate XML document. This will allow it to be edited without touching at all the XSLT code.

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

Sidebar

Related Questions

I'm using .NET 3.5 (C#) and the HTML Agility Pack to do some web
xml: <mode>1</mode> <mode>2</mode> <mode>3</mode> <mode>4</mode> <mode>5</mode> <mode>6</mode> <mode>7</mode> <mode>8</mode> <mode>9</mode> <mode>10</mode> <mode>11</mode> <mode>12</mode> i
I am trying to get the XPath "/deployment/service". Tested on this site: http://www.xmlme.com/XpathTool.aspx <?xml
I am trying to numerically integrate an arbitrary (known when I code) function in
I have a choice. I have a number of already ordered strings that I
I want to use jQuery to create an effect of a line drawing being

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.