Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xml-dev] using entitites in XSL

From: "G. Ken Holman" <gkholman@----------------.--->
To: xml-dev@-----.---.---
Date: 11/4/2007 1:11:00 PM
XSLT and XPath questions would be better posted to the following list:

   http://www.mulberrytech.com/xsl/xsl-list

There are a number of subscribers who would enthusiastically respond 
to such questions.

At 2007-11-04 03:21 -0800, Roman Banks wrote:
>I am customizing a footer template. As part of
>customization, I would like to insert copyright
>information as follows:

You give an example, but you don't define what you mean by 
"insert".  Do you want the end result to have the entity reference, 
or do you want the end result to have the entity content?

>     <xsl:when test="$double.sided = 0 and
>$position='left'">
>       <xsl:text>&j_copyright;</xsl:text>
>     </xsl:when>

The syntax you've used above is placing the copyright information 
into the stylesheet ... which indirectly will put the copyright 
information into the result ... but you are specifically asking the 
entity to be resolved *in* the stylesheet at the time you write the stylesheet.

So I'll assume for the rest of my post that you want the entity 
resolved with all of its text definition put into the result and not 
an entity reference placed in the result tree.

>As you can see, I would like to use an entity
>(&j_copyright) instead of a regular copyright text.

Then, because an XSLT file is an XML file, use XML syntax to do so.

>I defined this entity (which contains the copyright
>info) in my definitions.ent file where I store all my
>entities which I use in my XML sources. In my XSL
>customization layer, I called definitions.ent via
>xi:include.

XInclude is not designed for entity specification ... use standard 
XML syntax to work with entities.  Those who use XInclude are 
typically doing so to avoid using XML syntax to work with entities 
(though, admittedly, there are other attractive features).

>However, as you can already guess, this
>does not work when I try to compile a PDF. The
>compiler says that the entity is not defined. Is there
>any way to process entities inside XSL?

The same way you would for any XML file:

<!DOCTYPE xsl:stylesheet
[
<!ENTITY % ents SYSTEM 'definitions.ent'>
%ents;
]>
<xsl:stylesheet .....
...
.... &j_copyright; ....
...
</xsl:stylesheet>

Have you not rather considered maintaining the copyright information 
in a standalone XML file and then using the document() function in 
order to place it into your formatted result?  Relying on the XML 
physical entity structure is fraught with long-term maintenance 
risks.  It works at first and people jump in and use it, but the 
physical entity structure was designed to maintain one large XML file 
in smaller chunks, it is not well designed to *share* fragments of 
XML between different XML files.  You will be much safer to use 
standalone documents instead of entities for this kind of text.

I hope this helps.

. . . . . . . . . . . . . Ken

--
Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@C...
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent