(Whoops, I didn't paste it accurately into my email. But the code I actually used (see below) did include that part, and it still not did not yield the output I wanted. I tried this several times).
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:d=" http://docbook.org/ns/docbook" xmlns:date="http://exslt.org/dates-and-times" xmlns:saxon=" http://icl.com/saxon" exclude-result-prefixes="d date saxon" version="1.0"> <xsl:import href="../../../../1latest/docbook-xsl-ns-1.78.0/epub3/chunk.xsl"/> <xsl:param name="use.id.as.filename">1</xsl:param> <xsl:template match="chapter[@xml:id = 'mypreface']/para" mode="class.attribute" > <xsl:param name="width" select="local-name(.)"/> <xsl:attribute name="width">50px</xsl:attribute> </xsl:template> </xsl:stylesheet> On Mon, Jan 14, 2013 at 9:26 PM, Bob Stayton <[email protected]> wrote: > ** > Hi Robert, > You seem to have left off the mode="class.attribute" in your template. In > its current form it is processing in normal mode, which effectively kills > the output for that element. > > Bob Stayton > Sagehill Enterprises > [email protected] > > *From:* Robert Nagle <[email protected]> > *Sent:* Saturday, January 12, 2013 2:33 AM > *To:* apps docbook <[email protected]> > *Subject:* [docbook-apps] epub3 + adding customized attribute and value > to p tag? > > Hi, there, > > I am trying to add custom attribute values to all para tags inside a > specific chapter(the reason for this will be explained in a later > question). > > About a year or so ago, Bob suggested a way to insert new attributes and > values into html output. > https://lists.oasis-open.org/archives/docbook-apps/201108/msg00091.html > > However, when I try it using the epub 3 stylesheets, it doesn't succeed: > > My goal here is to add a custom attribute and value for every p tag inside > the <chapter xml:id="mypreface"> > > ******************************* MY SOURCE XML > <?xml version="1.0" encoding="UTF-8"?> > <?oxygen RNGSchema=" > http://www.oasis-open.org/docbook/xml/5.0/rng/docbook.rng" type="xml"?> > > <book xmlns="http://docbook.org/ns/docbook" xmlns:xi=" > http://www.w3.org/2001/XInclude" > xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" > xml:id="robert-book"> > > > <chapter xml:id="mypreface"> > <title>First</title> > <para> this is my good <emphasis role="bold">bold > </emphasis>first para</para> > <para> This is my good second para</para> > > </chapter> > > <chapter xml:id="bad1"> > <title>Second</title> > <para> this is my bad<emphasis role="bold">bold</emphasis>first > para</para> > <para> This is my bad second para</para> > </chapter> > > <chapter xml:id="bad2"> > <title>Third </title> > <para> 2this is my bad<emphasis role="bold">bold</emphasis>first > para</para> > <para> 2 This is my bad second para</para> > </chapter> > > *************************************************************MY > CUSTOMIZATION LAYER > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns="http://www.w3.org/1999/xhtml" xmlns:d=" > http://docbook.org/ns/docbook" > xmlns:date="http://exslt.org/dates-and-times" xmlns:saxon=" > http://icl.com/saxon" > exclude-result-prefixes="d date saxon" version="1.0"> > > <xsl:import > href="../../../../1latest/docbook-xsl-ns-1.78.0/epub3/chunk.xsl"/> > > <xsl:template match="chapter[@xml:id = 'mypreface']/para" > > <xsl:param name="width" select="local-name(.)"/> > <xsl:attribute name="width">50px</xsl:attribute> > </xsl:template> > </xsl:stylesheet> > > ********************************************************************* > (I also changing the xpath statement to d:chapter[@xml:id = > 'preface']/d:para with the same result) > > I would expect every p tag in the RESULT output to contain 'width="50px". > But instead I see for the first chapter this result: > > ... > <body><header></header> > <section class="chapter" title="First" epub:type="chapter" id="mypreface"> > <div class="titlepage"> > <div> > <div><h1 class="title">First</h1></div> > </div> > </div> > <p> this is my good <span class="bold"><strong>bold > </strong></span>first para</p> > <p> This is my good second para</p></section><footer></footer></body> > > ************************************************************************************ > > I'm not sure what I'm doing wrong; have I written the xpath wrong? For the > previous xsl snippet Bob suggested which I used for adding custom > attributes, this was pre-epub3. How would you do this in epub3? Or am I > making a syntax error of some sort? > > Thanks for your help > > > -- > Robert Nagle > 6121 Winsome Ln #56C, Houston TX 77057-5581 > (H) 713 893 3424/ (W) 832-251-7522 Carbon Neutral Since Jan 2010 > http://www.robertnagle.info > -- Robert Nagle 6121 Winsome Ln #56C, Houston TX 77057-5581 (H) 713 893 3424/ (W) 832-251-7522 Carbon Neutral Since Jan 2010 http://www.robertnagle.info
