[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: using entitites in XSL
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
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|