OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Exposing DocBook profiling information in HTML5 data elements


Hi there,
I have a use case where I'd like to convert DocBook to HTML, whilst
preserving the information from the 'revision' attributes of all
original DocBook elements. I'd like to pass these through as an HTML5
'data' attribute (named 'data-revision').

This way, I can profile the document dynamically with JavaScript, rather
than statically profiling the document at generation time.

I saw that something similar to the kind of 'passthrough' that I need
was being done with 'lang' attributes in html.xsl - if there's an
xml:lang attribute present, it's passed through as either a 'lang'
attribute (for HTML) or 'xml:lang' (for XHTML).

So I created a similar set of templates. However, they don't seem to be
picking anything up, or adding the appropriate attributes to the created
HTML elements.

Here's my initial stab at the problem from my XSL transformation layer:

<xsl:import href="html/docbook.xsl" />
	
	<xsl:template name="generate.html.revision">
	  <xsl:apply-templates select="."
	  mode="html.revision.attribute"/>
	</xsl:template>

	<xsl:template match="*" mode="html.revision.attribute">
		<!-- match the attribute name to the output type -->
		<xsl:choose>
			<xsl:when test="@revision and
			$stylesheet.result.type = 'html'">
				<xsl:attribute name="data-revision">
					<xsl:value-of
					select="@revision"/>
				</xsl:attribute>
			</xsl:when>
			<xsl:when test="@revision and
			$stylesheet.result.type = 'xhtml'">
				<xsl:attribute name="data-revision">
					<xsl:value-of
					select="@revision"/>
				</xsl:attribute>
			</xsl:when>
			<xsl:when test="@revision and
			$stylesheet.result.type = 'html'">
				<xsl:attribute name="data-revision">
					<xsl:value-of
					select="@revision"/>
				</xsl:attribute>
			</xsl:when>
			<xsl:when test="@revision and
			$stylesheet.result.type = 'xhtml'">
				<xsl:attribute name="data-revision">
					<xsl:value-of
					select="@revision"/>
				</xsl:attribute>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

I've tried removing the 'and $stylesheet.result.type = 'xhtml''
qualification, but it doesn't seem to make any difference.

I also tried this radically simpler version:

<xsl:import href="html/docbook.xsl" />

<xsl:template match="*" mode="html.revision.attribute">
		<!-- match the attribute name to the output type -->
		<xsl:choose>
			<xsl:when test="@revision">
				<xsl:attribute name="data-revision">
					<xsl:value-of
					select="@revision"/>
				</xsl:attribute>
			</xsl:when>
		</xsl:choose>
</xsl:template>

I'm using the 1.78.0 stylesheets.

Any ideas or suggestions would be greatly appreciated.

Regards,

Graeme


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]