Jump to content

Recommended Posts

I'm using XSLT to take XML and output to different XML.

One node has

<pronounce>&abreve;-b&umacr;s&prime; d&emacr;-t&ebreve;r&prime;&ebreve;nt</pronounce>

This <xsl:value-of select="$storage/mainentry/pronounce[1]" disable-output-escaping="yes"/>

Only outputs -bs d-trnt but I want it to output exactly what's in the document:
&abreve;-b&umacr;s&prime; d&emacr;-t&ebreve;r&prime;&ebreve;nt

Link to post
Share on other sites

In XML, those would be considered invalid entities, though it is valid if the document is HTML. You can escape them by turning every & into &amp;

<pronounce>&amp;abreve;-b&amp;umacr;s&amp;prime; d&amp;emacr;-t&amp;ebreve;ramp;&prime;&amp;ebreve;nt</pronounce>

Doing this straight through XSLT, I'm not certain, but you might want to set disable-output-escaping to "no" so that it will escape the characters.

Link to post
Share on other sites

That was submitted prematurely. Allow me to restate:

I'm using XSLT to take XML and output to different XML.
   One node has
   <pronounce>&abreve;-b&umacr;s&prime; d&emacr;-t&ebreve;r&prime;&ebreve;nt</pronounce>
   This <xsl:value-of select="$storage/mainentry/pronounce[1]" disable-output-escaping="yes"/>
   Only outputs -bs d-trnt but I want it to output exactly what's in the document:

&abreve;-b&umacr;s&prime; d&emacr;-t&ebreve;r&prime;&ebreve;nt

Or even transform the entities to the HTML equivalents.

Those entities are not declared in the document.
Is there a way to add a declaration to the style sheet? I cannot add the declaration to each of the thousands of documents.

Many thanks.

Link to post
Share on other sites

Sorry, yes, here's all of the methods I've tried:

                    <pronounce><xsl:value-of select="$storage/mainentry/pronounce[1]/text()" disable-output-escaping="yes"/></pronounce><br/>
                    <pronounce><xsl:value-of select="$storage/mainentry/pronounce[1]/text()" disable-output-escaping="no"/></pronounce>
                    <pronounce><xsl:value-of select="$storage/mainentry/pronounce" disable-output-escaping="yes"/></pronounce>
                    <pronounce><xsl:value-of select="$storage/mainentry/pronounce" disable-output-escaping="no"/></pronounce>
                    <pronounce><xsl:value-of select="$storage/mainentry/pronounce[1]" disable-output-escaping="yes"/></pronounce>
                    <pronounce><xsl:value-of select="$storage/mainentry/pronounce[1]" disable-output-escaping="no"/></pronounce>

The all produce same result:

    <pronounce>-bs d-trnt</pronounce>
    <pronounce>-bs d-trnt</pronounce>
    <pronounce>-bs d-trnt</pronounce>
    <pronounce>-bs d-trnt</pronounce>
    <pronounce>-bs d-trnt</pronounce>

Link to post
Share on other sites

I tried to test this in the browser but it rejected the XML because of undefined entities. Which XSLT engine are you using? It looks like your XSLT engine is allowing it to run but stripping out entities that it does not understand.

Link to post
Share on other sites

That is what's happening. It uses a custom-bulit engine.

This is how the $storage variable is being created:

                    <xsl:copy-of select="doc(concat('c:///service/assets/asset/id/', asset/@id, '/version/', asset/@version, '/storage/master/file'))"/>

Is there a better way to do that so that it wouldn't do this?

Link to post
Share on other sites

If I add this to the source file it works:

<!DOCTYPE mainentry [
<!ENTITY abreve "&#38;#x0103;">
]>

I get proper output of ă

However, I cannot add that to all of the files. Is there something I can do in the XSLT to accomplish this? Somehow insert that and other entity declarations either into the doc or with an include of somekind?

Link to post
Share on other sites

XSLT can only deal with valid XML. If you have another programming language available to you, you could have it replace the entities before sending the XML to the XSLT engine.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...