List Info

Thread: Creating a new admonition (db5)




Creating a new admonition (db5)
user name
2007-07-18 08:29:16
Hello,

I'd like to create a new admonition element, "DataShop
Tip", that 
resembles the existing "tip" element except that
instead of outputting 
the text "Tip" and the "tip" image, it
outputs "DataShop Tip" and an 
image of my own (and it gives the div element a
"datashop-tip" class name).

I followed Jirka Kosek's "DocBook specialization made
easy" [1], and 
I've come up with the following (don't laugh if this is
wildly 
inaccurate--I know nothing about Relax NG and little about
DTDs):

default namespace = "http://docbook.or
g/ns/docbook"
namespace db = "http://docbook.or
g/ns/docbook"
namespace r  = "http://nw
alsh.com/xmlns/schema-remap/"

div {
   db.datashoptip.role.attribute = attribute role 
   db.datashoptip.attlist =
     db.datashoptip.role.attribute?
     & db.common.attributes
     & db.common.linking.attributes
   db.datashoptip =
     [ r:remap [ db:tip [ ] ] ]
     element datashoptip { db.datashoptip.attlist, 
db.admonition.contentmodel }
}

# combined pattern
ds.admonition.blocks = db.datashoptip

include "file:///e:/docbook.rnc"
   {
     # datashop admonitions are permitted everywhere that
regular 
admonitions are
     db.admonition.blocks |= ds.admonition.blocks
   }


How does this look for the .rnc file? I'll also need to
create an XSLT 
template for this new element, so any advice for that step
would be 
appreciated as well.

Thanks,

Brett


[1] http://xmlguru.cz/2006/03/easy-docbook-specialization

------------------------------------------------------------
---------
To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
For additional commands, e-mail: docbook-apps-helplists.oasis-open.org


Re: Creating a new admonition (db5)
user name
2007-07-18 12:34:48
Hi Brett,

On Mittwoch, 18. Juli 2007, Brett Leber wrote:
>
> I'd like to create a new admonition element,
"DataShop Tip", 
> [...]
>
> default namespace = "http://docbook.or
g/ns/docbook"
> namespace db = "http://docbook.or
g/ns/docbook"
> namespace r  = "http://nw
alsh.com/xmlns/schema-remap/"
>
> div {
>    db.datashoptip.role.attribute = attribute role 
>    db.datashoptip.attlist =
>      db.datashoptip.role.attribute?
>      & db.common.attributes
>      & db.common.linking.attributes
>    db.datashoptip =
>      [ r:remap [ db:tip [ ] ] ]
>      element datashoptip { db.datashoptip.attlist,
> db.admonition.contentmodel }
> }
>
> # combined pattern
> ds.admonition.blocks = db.datashoptip
>
> include "file:///e:/docbook.rnc"
>    {
>      # datashop admonitions are permitted everywhere
that regular
> admonitions are
>      db.admonition.blocks |= ds.admonition.blocks
>    }
> How does this look for the .rnc file?

As far as I can tell, it works for me. 


> I'll also need to create an XSLT
> template for this new element, so any advice for that
step would be
> appreciated as well.

You have to write a customization layer[1]. It's a very
similar method 
that you applied for your DocBook schema.

Use the stylesheets from [2] with the name
"docbook-xsl-ns-snapshot.zip". 
Roughly speaking, it's "optimized" for DocBook 5.
;) 

Your customization layer looks like this:

------------------------------------------------------------
-------
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
    xmlns:d="http://docbook.or
g/ns/docbook"
    xmlnssl=&q
uot;http:/
/www.w3.org/1999/XSL/Transform">

<!-- Or replace it with .../html/chunk.xsl -->
<xsl:import
href="docbook-xsl-ns-snapshot/html/docbook.xsl"/&g
t; 

<xsl:template match="d:datashoptip">
  <!-- Insert your own changes -->
</xsl:template>

<xsl:template
match="d:datashoptip/d:title"/>

</xsl:stylesheet>
------------------------------------------------------------
-------

For details see html/admon.xsl. I think it should be easy,
as you need 
just to copy some contents from the db:note|db:caution...
template.


Hope that helps,
Tom

[1] http://www.sagehill.net/docbookxsl/CustomMethods.html
[2] http://docb
ook.sourceforge.net/snapshots/

-- 
Thomas Schraitle

------------------------------------------------------------
---------
To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
For additional commands, e-mail: docbook-apps-helplists.oasis-open.org


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )