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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:41:01+00:00 2026-06-05T04:41:01+00:00

I have a Xalan Java extension which returns a DocumentFragment. In my XSLT, I

  • 0

I have a Xalan Java extension which returns a DocumentFragment.

In my XSLT, I invoke it with something like:

<xsl:copy-of select="java:org.foo.myMethod($a, $b)"  /> 

The problem is that where the document fragment contains a text node containing an entity, for example “&#160;”, this is being inserted as &amp;#160;

Note that I do need to return a DocumentFragment, not a string, because that text node is just part of a tree of XML being returned.

I’m working around this issue as follows:

In the Java code:

Element amp = document.createElement("amp");
xhtmlBlock.appendChild(amp);
Text t = document.createTextNode("#160;");
amp.appendChild(t);

In the XSLT:

<xsl:apply-templates select="java:org.foo.myMethod($a, $b)" mode="amp-workaround" />    

<xsl:template match="@*|node()" mode="amp-workaround">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()" mode="amp-workaround" />
    </xsl:copy>
</xsl:template>

<xsl:template match="amp" mode="amp-workaround">
    <xsl:text disable-output-escaping="yes">&amp;</xsl:text><xsl:value-of select="."/>
</xsl:template>

Beware: this workaround only works in certain cases, which I’m still trying to pin down.

Is this a known issue in Xalan 2.7.1?

Is there a better approach (still using Java extensions which return DocumentFragment)?

  • 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-05T04:41:02+00:00Added an answer on June 5, 2026 at 4:41 am

    I don’t know Xalan particularly, but it looks to me as if your Java code is not creating a text node containing an entity or character reference, it is creating a text node containing the characters (&, #, 1, 6, 0, ;).

    Wouldn’t it be simplest just to include the character 160 in the returned string:

    Text t = document.createTextNode((char)160 + "");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working under java application which uses XSLT transformation. I have a lot
I have the following XSLT code that almost does what I want: <xsl:variable name=scoredItems
I have written sample program which uses XSLT to generate HTML response. Check below
I have a JSP which attaches a XSL to an XML document pulled from
I have an application which has been running happily under Java 1.5 for around
I am attempting to transform some Docbook XSL to HTML using Java / Xalan
I have a Java program (running in JDK 1.5 for now) which is getting
Have you ever created or encountered a self modifying code in Java? If yes,
Have you ever had to justify the choice over using .NET instead of Java
I've been using the Xalan XSLT processor in Eclipse STS 3.7, but I recently

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.