Jump to content

Special caracter in xsl-fo


Guest Acidbird
 Share

Recommended Posts

Guest Acidbird

Hello,I'm working on a xsl that will convert an xml file into an xsl-fo for pdf generation (fop). Both file are UTF-8 encoded. My problem comes from special caracter (like ® for example). They are stored in a <text> element of my xml using a symbol-value attribute witch is set to the hexadecimal code of the unicode caracter like that :

<text base-line="SUPER" symbol-family="BODY_TEXT" symbol-value="00AE"/>

My problem is that i can't display those caracter properly. I try to "build" the exepression unicodeValue; but It's those string that is displayed in the result, not the special caracter (Eg , in my resulting file, I have something like &#x... )Here is the Xsl that handle the parsing of the sybol-value attribute

	<xsl:template match="@symbol-value">	  <xsl:param name="contents"/>			<xsl:variable name="rolo">			  <xsl:value-of select="."/>		  </xsl:variable>		  		  <xsl:variable name="rolo2">			  <xsl:value-of disable-output-escaping="yes" select="concat('&#x',$rolo, ';' )"/>		  </xsl:variable>		  			  			  <xsl:text>[<xsl:copy-of select="$rolo2"/>]</xsl:text> <!-- <![CDATA[]]>&#x<xsl:value-of select="."/>; -->	</xsl:template>

Does someone has an idea on what is going wrong ? Or just an idea of how I could handle this differently, I'm really stuck on this one :) For the moment, my only solution is to create a template for each existing symbol like that

<xsl:template match="@symbol-value[.='00A2']">   ¢</xsl:template><xsl:template match="@symbol-value[.='20AC']">   €</xsl:template>...

Witch would be a mess to maintain :)

Link to comment
Share on other sites

Yeah, I've tried that one too. Never worked and I think I know why.The only real solution I ever came around was to actually write the literal character in the XML. Since it's UTF-8 encoded, it should be no problem to store it as is in the XML. Even if it was, you can always create an entity reference directly in the XML document.In other words, XSLT just doesn't allow you to "generate" character references.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...