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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:35:24+00:00 2026-06-15T05:35:24+00:00

Given the XSL template and XML below, here’s the HTML output i’m trying to

  • 0

Given the XSL template and XML below, here’s the HTML output i’m trying to achieve (more or less):

<p>
foo goes here
  <span class="content"><p>blah blah blah</p><p>blah blah blah</p></span>
bar goes here
  <span class="content">blah blah blah blah blah blah</span> 
</p>

Here is what is actually getting rendered (entire contents of <span.content> missing):

<p>
foo goes here
  <span class="content"></span>
bar goes here
  <span class="content">blah blah blah blah blah blah</span> 
</p>

Here’s my template (snippet):

 <xsl:template match="note[@type='editorial']">
   <span class="content">
     <xsl:apply-templates />
   </span>
 </xsl>
 <xsl:template match="p">
   <p>
     <xsl:apply-templates />
   </p>
 </xsl>

Here’s my xml:

<p>
foo goes here
  <note type="editorial"><p>blah blah blah</p><p>blah blah blah</p></note>
bar goes here
  <note type="editorial">blah blah blah blah blah blah</note> 
</p>

Rendering particular elements is not important. ie. I don’t care whether a <p> or <div> or <span> gets rendered, so long as none of the text elements are lost.
I would like to avoid creating a specific rule to match “p/note/p”, assuming that a <note> element can contain any arbitrary children.

I’m a total noob to xsl, so any additional tips or pointers would be really helpful.

Thanks in advance.

  • 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-15T05:35:26+00:00Added an answer on June 15, 2026 at 5:35 am

    OK, so I’m just fussing around and here’s the solution i finally came up with.

    Nested <p> tags just don’t work. Your browser doesn’t like them, and XSLT doesn’t like them either. So, I switched everything to <divs> and <spans>

    Also, I added a couple catch-all templates to the end of my template.

    Here’s the final version that’s working well enough for my purposes:

    <xsl:template match="note[@type='editorial']">
       <span class="content">
         <xsl:apply-templates />
       </span>
    </xsl:template>
    
    <xsl:template match="p">
      <div class="para">
        <xsl:apply-templates />
      </div>
    </xsl:template>
    
    <xsl:template match="*">
      <xsl:apply-templates />
    </xsl:template>
    
    <xsl:template match="text()">
      <xsl:value-of select="." />
    </xsl:template>
    

    h/t:

    http://www.dpawson.co.uk/xsl/sect2/defaultrule.html

    and How can xsl:apply-templates match only templates I have defined?

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

Sidebar

Related Questions

Given the XML <blockquote> <attribution>foo</attribution> <para>bar</para> </blockquote> I have the XSL template <xsl:template match=dbk:blockquote>
Given the following XML fragment: <foo> <bar>1</bar> <bar>2</bar> <bar>3</bar> </foo> The following XSL should
XML coding is given below <math> <mn> <mphantom>12</mphantom> </mn> </math> Output required: <?xml version='1.0'
Given the following XML: <?xml version=1.0 encoding=UTF-8 ?> <?xml-stylesheet type=text/xsl href=form.xsl?> <Document> <Translations> <Translation
Given the xml: <element>text</element> ... <element>text</element> And xsl: <xsl:for-each select=element> ... </xsl:for-each> What do
Given the following XML and XSL transformation, I'd expect two <node/> elements in the
Given a normal nhibernate config file: <?xml version=1.0?> <?xml-stylesheet type=text/xsl href=http://localhost/xmlStylesheets/nhibernate.xsl?> <hibernate-configuration xmlns=urn:nhibernate-configuration-2.2> <session-factory>
Why doesn't my XSL find anything to process in this XML? I am trying
Given the following Xml: <record> <category>Sport/Racket Sports/Tennis</category> <category>Sport/Racket Sports/Badminton</category> </record> I'm trying to break
I have the following xsl stylesheet: <xsl:stylesheet xmlns=http://www.w3.org/1999/xhtml xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:output method=xml encoding=utf-8/> <xsl:template match=/>

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.