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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:56:20+00:00 2026-05-19T10:56:20+00:00

I have about 4,000 html documents that i am trying to convert into django

  • 0

I have about 4,000 html documents that i am trying to convert into django templates using xslt. The problem that I am having is that xslt is escaping the ‘{‘ curly braces for template variables, when I try to include a template variable inside of an attribute tag;
my xslt file looks like this:

<xsl:template match="p">
    <p>
        <xsl:attribute name="nid"><xsl:value-of select="$node_id"/></xsl:attribute>
        <xsl:apply-templates select="*|node()"/>
    </p>
    <span>
        {% get_comment_count for thing '<xsl:value-of select="$node_id"/>' as node_count %}
        <a href="">{{ node_count }}</a> //This works as expected
    </span>
    <div>
        <xsl:attribute name="class">HControl</xsl:attribute>
        <xsl:text disable-output-escaping="yes">{% if node_count > 0 %}</xsl:text> // have to escape this because of the '>'
        <div class="comment-list">
            {% get_comment_list for thing '<xsl:value-of select="$node_id"/>' as node_comments %}
            {% for comment in node_comments %}
            <div class="comment {{ comment.object_id }}"> // this gets escaped
                <a>
                <xsl:attribute name="name">c{{ comment.id }}</xsl:attribute> //and so does this
                </a>
                <a>
                <xsl:attribute name="href">
                {% get_comment_permalink comment %}
                </xsl:attribute>
                permalink for comment #{{ forloop.counter }}
                </a>
                <div>
                {{ comment.comment }}
                </div>
            </div>
            {% endfor %}
        </div>
        {% endif %}
    </div>

the output looks something like this:

<div>
<p nid="50:1r:SB:1101S:5">
    <span class="Insert">B.  A person who violates this section is guilty of a class 1 misdemeanor.</span>
</p>
<span>
    <a href="">1</a>
</span>
<div class="HControl">
    <div class="comment-list">
        <div class="comment '{ comment.object_id }'"> // this should be class="comment #c123"
            <a name="c%7B%7B%20comment.id%20%7D%7D"></a> // this should name="c123"
            <a href="%7B%%20get_comment_permalink%20comment%20%%7D"> //this should be an href to the comment
                permalink for comment #1
            </a>
            <div>
                Well you should show some respect!
            </div>
        </div>
    </div>
</div>

I transform the file with lxml.etree and then pass the string to a django template object, and render it.
I just dont seem to understand how to get the xslt parser to leave the curly braces alone

  • 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-19T10:56:21+00:00Added an answer on May 19, 2026 at 10:56 am

    XSLT has its own purpose for curly braces – they are used in Attribute Value Templates, like this:

    <!-- $someVariableOrExpression will be evaluated here -->
    <div title="{$someVariableOrExpression}" />
    

    To get literal curly braces into attribute values in XSLT, you need to escape them, which is done by doubling them:

    <!-- the title will be "{$someVariableOrExpression}" here -->
    <div title="{{$someVariableOrExpression}}" />
    

    So if you want to output literal double curly braces, you need (guess what):

    <div title="{{{{$someVariableOrExpression}}}}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.