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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:16:54+00:00 2026-05-18T10:16:54+00:00

Suppose I have the following xml, what xsl do I need to transform the

  • 0

Suppose I have the following xml, what xsl do I need to transform the note tags inside the p tags to a sup tag?

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<root>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent<note>1</note> vel nisi non sapien venenatis vehicula. Nunc et dignissim ligula. Praesent aliquet nisl eget quam sollicitudin a faucibus eros dapibus. Aliquam cursus elit at tortor lacinia congue. Donec sit amet felis risus, a mollis ante. Integer sit amet massa sed metus semper cursus id id enim. Vestibulum felis nunc, pellentesque non lobortis et, porttitor eu libero. Curabitur eget nulla quam. Etiam erat arcu, vulputate sed volutpat consequat, adipiscing et tortor. Quisque imperdiet laoreet fermentum. Mauris ac felis vel lectus semper posuere. Etiam luctus augue et odio suscipit varius. Curabitur tincidunt purus quis tellus pretium imperdiet. In rhoncus rutrum orci, sed venenatis sem volutpat non. Curabitur tincidunt lacinia sem at luctus. Donec et diam eu massa interdum dapibus a et elit. Donec malesuada urna et nunc volutpat gravida.</p>
<p>Donec varius placerat venenatis. In neque sem, sollicitudin sed eleifend et, tristique eu turpis. Donec quis nisi lectus. Nullam gravida vestibulum arcu non aliquet. Nullam ut felis metus. Proin mollis tellus eu eros iaculis eget tristique leo fermentum. Pellentesque nec lorem vitae nibh eleifend euismod. Pellentesque nec gravida neque. Praesent mattis mi sed nisi sodales porta. Morbi risus mauris, convallis at condimentum a, interdum nec purus. Cras vulputate faucibus tempor. Aliquam eu dolor sed eros malesuada pharetra vitae vitae est. Suspendisse lacinia urna vitae mi bibendum quis<note>2</note> scelerisque augue tristique. Aenean at arcu tellus, eu placerat enim. Cras ultrices iaculis augue vitae pharetra. Praesent suscipit blandit scelerisque. Mauris et molestie purus. Vivamus volutpat enim sem, eget scelerisque turpis. Praesent viverra lectus in ipsum tristique blandit. Donec lobortis molestie purus, at feugiat leo rhoncus eget.</p>
<p>Vivamus eget convallis massa. Etiam convallis gravida tincidunt. Suspendisse tincidunt dignissim accumsan. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo placerat egestas. Donec convallis sodales volutpat. Quisque dapibus lobortis augue sit amet rhoncus. Nulla sed sem nisl, in feugiat orci. Quisque vehicula iaculis nisi ut auctor. Integer molestie nisl eget diam pharetra interdum. Mauris aliquet, libero vel congue egestas, velit est pretium leo, luctus commodo risus diam sed odio. Nullam pretium blandit ligula, quis commodo massa rhoncus eu. Nunc in hendrerit mi. Cras quis orci ut metus lacinia eleifend id eu nisi. Nunc id varius diam. Aliquam eu porta velit. Curabitur eget<note>3</note> odio neque, et aliquam nisi.</p>
<notes>
<note><nr>1</nr>Suspendisse tincidunt dignissim accumsan</note>
<note><nr>2</nr>Nunc et dignissim ligula</note>
<note><nr>3</nr>eget convallis massa</note>
</notes>
</root>

and xsl stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/root/*">
  <html>
  <body>
    <xsl:for-each select=".">
      <xsl:choose>
        <xsl:when test="name() = 'p'">
          <p><xsl:value-of select="." /></p>
        </xsl:when>
        <xsl:when test="name() = 'notes'">
          <p><xsl:value-of select="." /></p>
        </xsl:when>
      </xsl:choose>
    </xsl:for-each>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
  • 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-18T10:16:54+00:00Added an answer on May 18, 2026 at 10:16 am

    All you need to change the p/note to a sup is an identity template (search SO, there’s a lot of answers to this) and another template to match p/note (see below).

    But I would go for something like this since your stylesheet produces some what strange output, but it’s not necessarily what you wanted:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="1.0">
    
      <xsl:template match="root">
        <html>
          <body>
            <xsl:apply-templates/>
          </body>
        </html>
      </xsl:template>
    
      <xsl:template match="node() | @*">
        <xsl:copy>
          <xsl:apply-templates select="node() | @*"/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="p/note">
        <sup>
          <xsl:apply-templates/>
        </sup>
      </xsl:template>
    
      <xsl:template match="notes">
        <ol>
          <xsl:apply-templates>
            <xsl:sort select="nr" data-type="number"/>
          </xsl:apply-templates>
        </ol>
      </xsl:template>
    
      <xsl:template match="notes/note">
        <li>
          <xsl:apply-templates/>
        </li>
      </xsl:template>
    
      <xsl:template match="nr"/>
    
    </xsl:stylesheet>
    

    This will transform your data into a HTML document with p/note to a sup and notes/note to an ordered list.

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

Sidebar

Related Questions

Suppose I have the following xml template: <?xml version=1.0 encoding=UTF-8 ?> <myXML> <params> <param
Suppose I have the following XML file, and I want to use PowerShell (version
Suppose I have the following XML (which is the embedding of TEI annotation scheme
Suppose I have the the following xml: <package xmlns=http://example/namespace> <rating system=au-oflc>PG</rating> ... </package> To
Suppose I have following in my web.xml <filter-mapping> <filter-name>F1</filter-name> <url-pattern>/XYZ/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>F2</filter-name> <url-pattern>/XYZ/abc.do</url-pattern>
Suppose I have a directory structure like the following /a/b/testB.xml /a/c/testC.xml /a/testD.xml and I
Suppose I have the following XML <building> <phonenumber></phonenumber> <room> <phonenumber></phonenumber> </room> </building> Using building.getElementsByTagName('phonenumber')
Suppose I have the following XML, how should I update my XSD schema (described
I have the following XSLT question: Suppose I have this XML <items> <item> <type>dog</type>
Suppose I have the following XML structure: <root> <item> <item1>some text is <b>here</b></item1> <item2>more

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.