[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] XInclude in sitemap problem
Hi, I found a solution that might be worth for inclusion in the docbook-xsl distro. Basically I enclose everything of the ttl and xreftext sections of a target db in a CDATA section. (common/targets.xsl) Then I ensure that the output of the xreftext is not xml encoded. (common/olink.xsl). Cheers, Marco <?xml version='1.0'?> <!-- customization layer for overloading templates of the common section --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version='1.0'> <!-- overload template "div" and "obj" from common/targets.xsl --> <!-- enclose content of ttl and xreftext in CDATA section --> <xsl:template name="div"> <xsl:param name="nd" select="."/> <div> <xsl:call-template name="attrs"> <xsl:with-param name="nd" select="$nd"/> </xsl:call-template> <ttl> <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text> <xsl:apply-templates select="$nd" mode="title.markup"> <xsl:with-param name="verbose" select="0"/> </xsl:apply-templates> <xsl:text disable-output-escaping="yes">]]></xsl:text> </ttl> <xreftext> <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text> <xsl:choose> <xsl:when test="$nd/@xreflabel"> <xsl:call-template name="xref.xreflabel"> <xsl:with-param name="target" select="$nd"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="$nd" mode="xref-to"> <xsl:with-param name="verbose" select="0"/> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> <xsl:text disable-output-escaping="yes">]]></xsl:text> </xreftext> <xsl:apply-templates mode="olink.mode"/> </div> </xsl:template> <xsl:template name="obj"> <xsl:param name="nd" select="."/> <obj> <xsl:call-template name="attrs"> <xsl:with-param name="nd" select="$nd"/> </xsl:call-template> <ttl> <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text> <xsl:apply-templates select="$nd" mode="title.markup"> <xsl:with-param name="verbose" select="0"/> </xsl:apply-templates> <xsl:text disable-output-escaping="yes">]]></xsl:text> </ttl> <xreftext> <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text> <xsl:choose> <xsl:when test="$nd/@xreflabel"> <xsl:call-template name="xref.xreflabel"> <xsl:with-param name="target" select="$nd"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="$nd" mode="xref-to"> <xsl:with-param name="verbose" select="0"/> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> <xsl:text disable-output-escaping="yes">]]></xsl:text> </xreftext> </obj> </xsl:template> <!-- overload olink.hottext template from common/olink.xsl --> <!-- write xreftext trough value-of instead of copy-of --> <xsl:template name="olink.hottext"> <xsl:param name="target.database"/> <xsl:param name="olink.lang" select="''"/> <xsl:param name="olink.key" select="''"/> <xsl:param name="referrer" select="."/> <xsl:param name="xrefstyle"> <xsl:choose> <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0"> <xsl:value-of select="@role"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="@xrefstyle"/> </xsl:otherwise> </xsl:choose> </xsl:param> <xsl:choose> <!-- If it has elements or text (not just PI or comment) --> <xsl:when test="child::text() or child::*"> <xsl:apply-templates/> </xsl:when> <xsl:when test="$olink.key != ''"> <!-- Get the xref text for this record --> <xsl:variable name="xref.text" > <xsl:for-each select="$target.database" > <xsl:value-of disable-output-escaping="yes" select="key('targetptr-key', $olink.key)/xreftext/node()" /> </xsl:for-each> </xsl:variable> <xsl:variable name="xref.number" > <xsl:for-each select="$target.database" > <xsl:value-of select="key('targetptr-key', $olink.key)/@number" /> </xsl:for-each> </xsl:variable> <xsl:variable name="target.elem" > <xsl:for-each select="$target.database" > <xsl:value-of select="key('targetptr-key', $olink.key)/@element" /> </xsl:for-each> </xsl:variable> <xsl:variable name="lang"> <xsl:variable name="candidate"> <xsl:for-each select="$target.database" > <xsl:value-of select="key('targetptr-key', $olink.key)/@lang" /> </xsl:for-each> </xsl:variable> <xsl:choose> <xsl:when test="$candidate != ''"> <xsl:value-of select="$candidate"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$olink.lang"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="targetdoc"> <xsl:value-of select="substring-before($olink.key, '/')"/> </xsl:variable> <xsl:choose> <xsl:when test="$xrefstyle != '' and starts-with(normalize-space($xrefstyle), 'select:') and (contains($xrefstyle, 'nodocname') or contains($xrefstyle, 'nopage')) and not(contains($xrefstyle, 'title')) and not(contains($xrefstyle, 'label'))"> <xsl:copy-of select="$xref.text"/> </xsl:when> <xsl:when test="$xrefstyle != ''"> <xsl:if test="$olink.debug != 0"> <xsl:message> <xsl:text>xrefstyle is '</xsl:text> <xsl:value-of select="$xrefstyle"/> <xsl:text>'.</xsl:text> </xsl:message> </xsl:if> <xsl:variable name="template"> <xsl:choose> <xsl:when test="starts-with(normalize-space($xrefstyle), 'select:')"> <xsl:call-template name="make.gentext.template"> <xsl:with-param name="xrefstyle" select="$xrefstyle"/> <xsl:with-param name="purpose" select="'olink'"/> <xsl:with-param name="referrer" select="."/> <xsl:with-param name="target.elem" select="$target.elem"/> </xsl:call-template> </xsl:when> <xsl:when test="starts-with(normalize-space($xrefstyle), 'template:')"> <xsl:value-of select="substring-after( normalize-space($xrefstyle), 'template:')"/> </xsl:when> <xsl:otherwise> <!-- Look for Gentext template with @style attribute --> <!-- Must compare to no style value because gentext.template falls back to no style --> <xsl:variable name="xref-context"> <xsl:call-template name="gentext.template"> <xsl:with-param name="context" select="'xref'"/> <xsl:with-param name="name" select="$target.elem"/> <xsl:with-param name="lang" select="$lang"/> </xsl:call-template> </xsl:variable> <xsl:variable name="styled-xref-context"> <xsl:call-template name="gentext.template"> <xsl:with-param name="context" select="'xref'"/> <xsl:with-param name="name" select="$target.elem"/> <xsl:with-param name="lang" select="$lang"/> <xsl:with-param name="xrefstyle" select="$xrefstyle"/> </xsl:call-template> </xsl:variable> <xsl:variable name="xref-number-context"> <xsl:call-template name="gentext.template"> <xsl:with-param name="context" select="'xref-number'"/> <xsl:with-param name="name" select="$target.elem"/> <xsl:with-param name="lang" select="$lang"/> </xsl:call-template> </xsl:variable> <xsl:variable name="styled-xref-number-context"> <xsl:call-template name="gentext.template"> <xsl:with-param name="context" select="'xref-number'"/> <xsl:with-param name="name" select="$target.elem"/> <xsl:with-param name="lang" select="$lang"/> <xsl:with-param name="xrefstyle" select="$xrefstyle"/> </xsl:call-template> </xsl:variable> <xsl:variable name="xref-number-and-title-context"> <xsl:call-template name="gentext.template"> <xsl:with-param name="context" select="'xref-number-and-title'"/> <xsl:with-param name="name" select="$target.elem"/> <xsl:with-param name="lang" select="$lang"/> </xsl:call-template> </xsl:variable> <xsl:variable name="styled-xref-number-and-title-context"> <xsl:call-template name="gentext.template"> <xsl:with-param name="context" select="'xref-number-and-title'"/> <xsl:with-param name="name" select="$target.elem"/> <xsl:with-param name="lang" select="$lang"/> <xsl:with-param name="xrefstyle" select="$xrefstyle"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="$xref-number-and-title-context != $styled-xref-number-and-title-context and $xref.number != '' and $xref.with.number.and.title != 0"> <xsl:value-of select="$styled-xref-number-and-title-context"/> </xsl:when> <xsl:when test="$xref-number-context != $styled-xref-number-context and $xref.number != ''"> <xsl:value-of select="$styled-xref-number-context"/> </xsl:when> <xsl:when test="$xref-context != $styled-xref-context"> <xsl:value-of select="$styled-xref-context"/> </xsl:when> <xsl:when test="$xref-number-and-title-context != '' and $xref.number != '' and $xref.with.number.and.title != 0"> <xsl:value-of select="$xref-number-and-title-context"/> <xsl:if test="$olink.debug"> <xsl:message> <xsl:text>Olink error: no gentext template</xsl:text> <xsl:text> exists for xrefstyle '</xsl:text> <xsl:value-of select="$xrefstyle"/> <xsl:text>' for element '</xsl:text> <xsl:value-of select="$target.elem"/> <xsl:text>' in language '</xsl:text> <xsl:value-of select="$lang"/> <xsl:text>' in context 'xref-number-and-title</xsl:text> <xsl:text>'. Using template without @style.</xsl:text> </xsl:message> </xsl:if> </xsl:when> <xsl:when test="$xref-number-context != '' and $xref.number != ''"> <xsl:value-of select="$xref-number-context"/> <xsl:if test="$olink.debug"> <xsl:message> <xsl:text>Olink error: no gentext template</xsl:text> <xsl:text> exists for xrefstyle '</xsl:text> <xsl:value-of select="$xrefstyle"/> <xsl:text>' for element '</xsl:text> <xsl:value-of select="$target.elem"/> <xsl:text>' in language '</xsl:text> <xsl:value-of select="$lang"/> <xsl:text>' in context 'xref-number</xsl:text> <xsl:text>'. Using template without @style.</xsl:text> </xsl:message> </xsl:if> </xsl:when> <xsl:when test="$xref-context != ''"> <xsl:value-of select="$xref-context"/> <xsl:if test="$olink.debug"> <xsl:message> <xsl:text>Olink error: no gentext template</xsl:text> <xsl:text> exists for xrefstyle '</xsl:text> <xsl:value-of select="$xrefstyle"/> <xsl:text>' for element '</xsl:text> <xsl:value-of select="$target.elem"/> <xsl:text>' in language '</xsl:text> <xsl:value-of select="$lang"/> <xsl:text>' in context 'xref</xsl:text> <xsl:text>'. Using template without @style.</xsl:text> </xsl:message> </xsl:if> </xsl:when> <xsl:otherwise> <xsl:message> <xsl:text>Olink error: no gentext template</xsl:text> <xsl:text> exists for xrefstyle '</xsl:text> <xsl:value-of select="$xrefstyle"/> <xsl:text>' for element '</xsl:text> <xsl:value-of select="$target.elem"/> <xsl:text>' in language '</xsl:text> <xsl:value-of select="$lang"/> <xsl:text>'. Trying '%t'.</xsl:text> </xsl:message> <xsl:value-of select="'%t'"/> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:if test="$olink.debug != 0"> <xsl:message> <xsl:text>Olink debug: xrefstyle template is '</xsl:text> <xsl:value-of select="$template"/> <xsl:text>'.</xsl:text> </xsl:message> </xsl:if> <xsl:call-template name="substitute-markup"> <xsl:with-param name="template" select="$template"/> <xsl:with-param name="title"> <xsl:for-each select="$target.database" > <xsl:value-of select="key('targetptr-key', $olink.key)/ttl" /> </xsl:for-each> </xsl:with-param> <xsl:with-param name="label"> <xsl:for-each select="$target.database" > <xsl:value-of select="key('targetptr-key', $olink.key)/@number" /> </xsl:for-each> </xsl:with-param> <xsl:with-param name="pagenumber"> <xsl:for-each select="$target.database" > <xsl:value-of select="key('targetptr-key', $olink.key)/@page" /> </xsl:for-each> </xsl:with-param> <xsl:with-param name="docname"> <xsl:for-each select="$target.database" > <xsl:value-of select="key('targetdoc-key', $targetdoc)/div[1]/ttl" /> </xsl:for-each> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:when test="$use.local.olink.style != 0"> <xsl:variable name="template"> <xsl:call-template name="gentext.template"> <xsl:with-param name="context" select="'xref'"/> <xsl:with-param name="name" select="$target.elem"/> <xsl:with-param name="lang" select="$lang"/> </xsl:call-template> </xsl:variable> <xsl:call-template name="substitute-markup"> <xsl:with-param name="template" select="$template"/> <xsl:with-param name="title"> <xsl:for-each select="$target.database" > <xsl:value-of select="key('targetptr-key', $olink.key)/ttl" /> </xsl:for-each> </xsl:with-param> <xsl:with-param name="label"> <xsl:for-each select="$target.database" > <xsl:value-of select="key('targetptr-key', $olink.key)/@number" /> </xsl:for-each> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:when test="$xref.text !=''"> <xsl:copy-of select="$xref.text"/> </xsl:when> <xsl:otherwise> <xsl:message> <xsl:text>Olink error: no generated text for </xsl:text> <xsl:text>targetdoc/targetptr/lang = '</xsl:text> <xsl:value-of select="$olink.key"/> <xsl:text>'.</xsl:text> </xsl:message> <xsl:text>????</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="@targetdoc != '' or @targetptr != ''"> <xsl:if test="$olink.key != ''"> <xsl:message> <xsl:text>Olink error: no generated text for </xsl:text> <xsl:text>targetdoc/targetptr/lang = '</xsl:text> <xsl:value-of select="$olink.key"/> <xsl:text>'.</xsl:text> </xsl:message> </xsl:if> <xsl:text>????</xsl:text> </xsl:when> <xsl:otherwise> <!-- old style olink --> <xsl:call-template name="olink.outline"> <xsl:with-param name="outline.base.uri" select="unparsed-entity-uri(@targetdocent)"/> <xsl:with-param name="localinfo" select="@localinfo"/> <xsl:with-param name="return" select="'xreftext'"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> -------- Original-Nachricht -------- > Datum: Thu, 14 Aug 2008 16:58:17 +0200 > Von: mercuron@gmx.ch > An: docbook-apps@lists.oasis-open.org > Betreff: [docbook-apps] XInclude in sitemap problem > Hi, > > I ran into a problem with a sitemap that includes some target dbs through > XInclude. > I'm using Xalan-2.7.0 with Xerces-2.7.1 and docbook-xsl-1.73.2. > > Some of the <ttl> and <xreftext> tags of my target db contain named xml > entities (such as ”). > When xinclude tries to parse these entities it fails, because it cannot > resolve these entities: > 14-Aug-08 16:36:50.489 XsltUtil$3: XSLT Transformation Info: Can not load > requested doc: Error attempting to parse XML file > (href='../../src/hcss/um/xml/html_umtarget.db'). at > file:/c:/data/herschel/temp/ia_document/docbook/xsl/common/olink.xsl [38:55] > 14-Aug-08 16:36:50.489 XsltUtil$3: XSLT Transformation Info: Olink error: > could not open target database > 'file:/c:/data/herschel/out/hcss/doc/src/../config/html/sitemap.xml'. at > file:/c:/data/herschel/temp/ia_document/docbook/xsl/common/olink.xsl [52:20] > > If I manually replace the entities everything is fine. > > Is there any way to force the docbook stylesheets not to use named > entities for the target db? > Are there any other tricks? > > Cheers, > Marco > > ---------------------------------------------------- > Sample sitemap > > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE targetset SYSTEM "../targetdatabase.dtd" > > <targetset xmlns:xi="http://www.w3.org/2001/XInclude" > > <targetsetinfo> > Global sitemap for the HCSS documentation infrastructure > </targetsetinfo> > <sitemap> > <dir name="doc"> > <dir name="hcss"> > <dir name="um"> > <dir name="html"> > <document targetdoc="um" baseuri=""> > <xi:include > href="../../src/hcss/um/xml/html_umtarget.db" > > <xi:fallback></xi:fallback> > </xi:include> > </document> > </dir> > </dir> > <dir name="dm"> > <dir name="html"> > <document targetdoc="dm" baseuri=""> > <xi:include > href="../../src/hcss/dm/xml/html_dmtarget.db" > > <xi:fallback></xi:fallback> > </xi:include> > </document> > </dir> > </dir> > ... > </dir> > </dir> > </sitemap> > </targetset> > -------------------------------------------------------- > Extract from html_umtarget.db > ... > <div element="section" href="preface.html#N1001D" number="1"> > <ttl>Brief Overview</ttl> > <xreftext>Section 1, “Brief > Overview”</xreftext> > </div> > ... > -------------------------------------------------------- > -- -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]