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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:57:55+00:00 2026-06-11T13:57:55+00:00

Trying to code a transform here in XSLT 2.0. What my source document looks

  • 0

Trying to code a transform here in XSLT 2.0.

What my source document looks like (malformed but that is what I’m dealing with):

<p>
       <a>
           WANT TO GRAB TEXT NODE HERE
           <br/>
           <br/>
           <i> WORD </i> 
           DEFINITION TEXT NODE HERE
           <br/>
           <br/>
           <i> WORD </i> 
           DEFINITION TEXT NODE HERE
       </a>
</p>

My goal is to get this into our current DTD standard of a definition list so my output looks something along these lines:

<p> WANT TO GRAB TEXT NODE HERE </p>
<dl>
    <dlentry>
         <dt><i> WORD </i></dt>
         <dd> ANOTHER TEXT NODE HERE <dd>
         <dt><i> WORD </i></dt>
         <dd> ANOTHER TEXT NODE HERE <dd>
    <dlentry>
<dl>

Here is a code snippet from my current transform:

**<xsl:template match="a[descendant::i and descendant::br]/node()[1]">
   <p>
     <xsl:value-of select="." />
   </p> 
</xsl:template>**

<xsl:template match="p[string-length(.) gt 600]">
    <dl>
        <dlentry>
            <xsl:apply-templates />
        </dlentry>
    </dl>
</xsl:template>

<xsl:template match="i">
    <dt>
        <i>
            <xsl:value-of select="."/>
        </i>
    </dt>
</xsl:template>

<xsl:template match="text()[preceding-sibling::*[1][self::i]]">
    <dd>
        <xsl:value-of select="normalize-space()"/>
    </dd>
</xsl:template>

The output to my transform looks like this:

<dl>
    <dlentry>
         <p> WANT TO GRAB TEXT NODE HERE </p>
         <dt><i> WORD </i></dt>
         <dd> ANOTHER TEXT NODE HERE </dd>
         <dt><i> WORD </i></dt>
         <dd> ANOTHER TEXT NODE HERE </dd>
    </dlentry>
</dl>

I would like that <p> to be above <dl> and on the same level. Any ideas?

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-11T13:57:56+00:00Added an answer on June 11, 2026 at 1:57 pm

    This:

      <xsl:template match="p[string-length(.) &gt; 600]">
        <p>
          <xsl:value-of select="a/text()[1]"/>
        </p>
        <dl>
          <dlentry>
            <xsl:apply-templates select="a/node()[position()>1]"/>
          </dlentry>
        </dl>
      </xsl:template>
    
      <xsl:template match="i">
        <dt>
          <i>
            <xsl:value-of select="."/>
          </i>
        </dt>
      </xsl:template>
    
      <xsl:template match="text()[preceding-sibling::*[1][self::i]]">
        <dd>
          <xsl:value-of select="normalize-space()"/>
        </dd>
      </xsl:template>
    

    should work – it handles the initial text node within the <a> tag separately, and then applies the templates on the other nodes (position()>1)

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

Sidebar

Related Questions

I'm trying to write an XSLT that will transform an XML document that I
I am trying to code an application that monitors sms messages. I want to
I've written a simple XML Document that I am trying to transform with an
I am having an issue converting type. I was trying code like this (minimal,
I m trying write code that after reset set up rrpmax as 3000. It
I am trying to code a widget that collates Tweets from multiple sources as
I'm trying to use XSLT to create Edge Side Includes html blocks. Here is
I have the following code that applies a XSLT style Test.Xml.xslTransform = function(xml, xsl)
Here is my code for moving in the four cardinal directions: if (Input.GetKeyDown(KeyCode.RightArrow)){ transform.forward
I'm trying to get a Hough transform to work in MATLAB, but I'm having

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.