-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graphic or logo in the header #44
base: develop
Are you sure you want to change the base?
Changes from 3 commits
7ed9c20
e911f56
3877f83
9dad7d6
f89141f
f9c4c33
ffcf757
c324c08
6f34d84
4b4d7c8
283b9bc
339280c
17aa61d
547da13
c6a9877
0e48460
bad3751
a5f09fd
4ad0914
5afd918
b554bf2
73982f8
7750465
39ac4fe
56f952d
ac67984
8667d2d
6e644b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
License CC BY-NC-SA 3.0 | ||
|
||
This work is licensed under the | ||
"Namensnennung – Keine kommerzielle Nutzung – Weitergabe unter | ||
gleichen Bedingungen 3.0 Deutschland (CC BY-NC-SA 3.0)" | ||
http://creativecommons.org/licenses/by-nc-sa/3.0/de/deed.de | ||
|
||
Read the English translation here: | ||
|
||
"Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)" | ||
http://creativecommons.org/licenses/by-nc-sa/3.0/ | ||
|
||
--> | ||
<?xml-model href="file:../5.1/dbref.rnc" type="application/relax-ng-compact-syntax"?> | ||
<section xml:id="dbc.fo.graphic-pageheader" remap="topic" userlevel="easy" | ||
xmlns="http://docbook.org/ns/docbook" | ||
xmlns:xi="http://www.w3.org/2001/XInclude" | ||
xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<title>Inserting Graphics to your Page Headers or Footers</title> | ||
<info> | ||
<author> | ||
<personname> | ||
<firstname>Peter</firstname> | ||
<surname>Schmelzer</surname> | ||
</personname> | ||
</author> | ||
<keywordset> | ||
<keyword>page header</keyword> | ||
<keyword>block</keyword> | ||
<keyword>format</keyword> | ||
<keyword>page</keyword> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add additional keywords like "header" and "footer". I would remove block, it's quite general and as such almost useless. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
</keywordset> | ||
<subjectset> | ||
<subject> | ||
<subjectterm>graphic</subjectterm> | ||
</subject> | ||
</subjectset> | ||
</info> | ||
|
||
<section role="problem"> | ||
<title>Problem</title> | ||
<para>You need to know how to insert a graphic in your page header or footer.</para> | ||
</section> | ||
|
||
<section role="solution"> | ||
<title>Solution</title> | ||
<para>First of all, you need to create a customization layer in your | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically, this is all nice and correct. However, not everybody read the book from start to end. Usually, users see a topic, jump in and read. That's why you cannot expect they know all the terms and workflows (for example, "customization layer"). I would suggest to structure the solution section like this:
After you did your "introduction", give the reader a procedure with a step-by-step instruction how to create this solution. You can use Creating Permalinks as a blueprint or the XML file Appyling that style to this topic would mean:
I guess, it would only need 3 to 4 steps. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
customization stylesheet containing the following code:</para> | ||
<programlisting><!-- Path and name of your graphic file--> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two issues:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Further ideas which makes handling of such files easier:
If you like this approach, I'd recommend the following:
<example xml:id="ex.fo.XXXXX">
<title>Some good title (<filename>YOUR_STYLESHEET.xsl</filename>)</title>
<info>
<output xmlns="urn:x-toms:docbook-ext">
<filename>logo/YOUR_STYLESHEET.xsl</filename>
</output>
</info>
<programlistingco>
<areaspec>
<!-- Add your callouts through <area/> -->
</areaspec>
<programlisting language="xml" linenumbering="numbered"
><xi:include href="logo/YOUR_STYLESHEET.xsl" parse="text"
/></programlisting>
</programlistingco>
</example> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, but with a similar way. I've placed all necessary files below the folder "graphic-pageheader/". |
||
<xsl:param name="header.image.filename">{$img.src.path}your-graphic.svg</xsl:param> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That won't work because you've included it as text. Text won't be replaced, you need the <xsl:param name="header.image.filename" select="concat($img.src.path, 'your-graphic.svg')"/> Another idea from an implementation perspective: would it better to separate the logo file name from any path? In other words, the parameter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what you mean. Do you mean this: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My idea was that <xsl:param name="header.image.filename">your-graphic.svg</xsl:param> The complete path would be built at the position where it is needed by concatenating it with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. That makes sense. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Almost. 😉 These lines are correct: <xsl:param name="img.src.path">./Images/</xsl:param>
<xsl:param name="header.image.filename">your-graphic.svg</xsl:param> A little bit deeper you use the parameter <xsl:call-template name="fo-external-image"><co xml:id="co.topic.graphic-pageheader.template"/>
<xsl:with-param name="filename" select="concat($img.src.path, $header.image.filename)"/><co xml:id="co.topic.graphic-pageheader.file"/>>
</xsl:call-template> Keep in mind the following changes in comparison to your code:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
<!-- Header rule yes (1) / no (0) --> | ||
<xsl:param name="header.rule" select="0"/> | ||
|
||
<xsl:template name="header.content"><co xml:id="co.topic.graphic-pageheader.content"/> | ||
<xsl:param name="pageclass" select="''"<co xml:id="co.topic.graphic-pageheader.variables"/> | ||
<xsl:param name="sequence" select="''"/> | ||
<xsl:param name="position" select="''"/> | ||
<xsl:param name="gentext-key" select="''"/> | ||
<fo:block><co xml:id="co.topic.graphic-pageheader.block"/> | ||
<!-- sequence can be odd, even, first, blank --> | ||
<!-- position can be left, center, right --> | ||
<xsl:choose> | ||
<xsl:when test="$sequence = 'blank'"> | ||
<!-- nothing --><co xml:id="co.topic.graphic-pageheader.blank"/> | ||
</xsl:when> | ||
|
||
<xsl:when test="$position='left'"> | ||
<!-- Same for odd, even, empty, and blank sequences --> | ||
<!-- nothing --> | ||
</xsl:when> | ||
|
||
<xsl:when test="($sequence='odd' or $sequence='even') and $position='center'"> | ||
<!-- nothing --> | ||
</xsl:when> | ||
|
||
<xsl:when test="$position='center'"><co xml:id="co.topic.graphic-pageheader.center"/> | ||
<!-- nothing for empty and blank sequences --> | ||
</xsl:when> | ||
|
||
<xsl:when test="$position='right'"><co xml:id="co.topic.graphic-pageheader.right"/> | ||
<!-- Same for odd, even, empty, and blank sequences --> | ||
<fo:external-graphic content-height="25mm"><co xml:id="co.topic.graphic-pageheader.height"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmn... hard-coded values are not always as constant as we wish. 😉 I would suggest to outsource it into a parameter. This gives the user the chance to change it as needed. |
||
<xsl:attribute name="src"><co xml:id="co.topic.graphic-pageheader.attribute"/> | ||
<xsl:call-template name="fo-external-image"><co xml:id="co.topic.graphic-pageheader.template"/> | ||
<xsl:with-param name="filename" select="$header.image.filename"/> | ||
<co xml:id="co.topic.graphic-pageheader.file"/>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the line break and add the |
||
</xsl:call-template> | ||
</xsl:attribute> | ||
</fo:external-graphic> | ||
</xsl:when> | ||
|
||
<xsl:when test="$sequence = 'first'"> | ||
<!-- nothing for first pages --> | ||
</xsl:when> | ||
|
||
<xsl:when test="$sequence = 'blank'"> | ||
<!-- nothing for blank pages --> | ||
</xsl:when> | ||
</xsl:choose> | ||
</fo:block> | ||
</xsl:template></programlisting> | ||
<calloutlist> | ||
<callout arearefs="co.topic.graphic-pageheader.content"> | ||
<para>We assume that your graphic should be placed in the header | ||
of all pages except title pages.</para> | ||
</callout> | ||
<callout arearefs="co.topic.graphic-pageheader.variables"> | ||
<para>The content of the necessary variables needs to be cleared.</para> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's the default value. This value is used, when the caller doesn't define the parameter. |
||
</callout> | ||
<callout arearefs="co.topic.graphic-pageheader.block"> | ||
<para>A <tag>block</tag>-element creates a rectangle area on a page | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
which can contain <tag>lists</tag>, <tag>tables</tag> or <tag>graphics</tag> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid these tag elements for list, tables, and graphics. They are not specific elements, but concepts. |
||
.</para> | ||
</callout> | ||
<callout arearefs="co.topic.graphic-pageheader.blank"> | ||
<para>Here you can place an banner like '<emphasis>This page is | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
intentionally left blank'</emphasis> or so.</para> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the "or so". |
||
</callout> | ||
<callout arearefs="co.topic.graphic-pageheader.center"> | ||
<para>This is a good place for the chapter title.</para> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you do that? That can be a good place for the discussion. |
||
</callout> | ||
<callout arearefs="co.topic.graphic-pageheader.right"> | ||
<para>This is the place where we want to place our graphic. The | ||
graphic should be visible on all pages on the right side.</para> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This statement should be added before you present your stylesheet. |
||
</callout> | ||
<callout arearefs="co.topic.graphic-pageheader.height"> | ||
<para>The graphic picture is too big, so we limit his height to 25mm. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rephrase the sentence as: To avoid pictures which are too big for the headline, we limit its height to 25mm. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
When you specify only one parameter like <tag>height</tag>or<tag>width</tag>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add spaces between "height", "or", and "width". |
||
your graphic will be scaled with the <link | ||
xlink:href="#li.fo.external-graphics">correct aspect ratio</link>.</para> | ||
</callout> | ||
<callout arearefs="co.topic.graphic-pageheader.attribute"> | ||
<para>We will give the graphic which will be used the attribute. | ||
<emphasis>src</emphasis>.</para> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That isn't an English sentence. 😉 Maybe something like this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. :-) |
||
</callout> | ||
<callout arearefs="co.topic.graphic-pageheader.template"> | ||
<para>The template which is called to import and place the graphic.</para> | ||
</callout> | ||
<callout arearefs="co.topic.graphic-pageheader.file"> | ||
<para>Our file defined at the top of our customization layer.</para> | ||
</callout> | ||
</calloutlist> | ||
</section> | ||
<section role="discussion"> | ||
<title>Discussion</title> | ||
<para>If you wish to place your graphic within the footer, replace | ||
<tag>header.content</tag>with<tag>footer.content</tag>.</para> | ||
</section> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The discussion is a bit... well, very short. 😉 Usually, I apply the following approach for each topic:
Overall, I try to make the solution more general, but the discussion more specific. As a reader, I would expect some additional ideas. Some ideas that come to my mind and could be added:
Of course, you don't have to describe all of them. It's just an idea what can be included. |
||
<section role="seealso"> | ||
<title>See Also</title> | ||
<itemizedlist> | ||
<listitem xml:id="li.fo.external-graphics"> | ||
<para>Full parameter description for <tag>fo:external-graphic</tag><link | ||
xlink:href="http://www.w3.org/TR/xsl/#fo_external-graphic"/></para> | ||
</listitem> | ||
<listitem> | ||
<para>Parameter description for <tag>xsl:attribute</tag><link | ||
xlink:href="https://www.w3schools.com/xml/ref_xsl_el_attribute.asp"/></para> | ||
</listitem> | ||
<listitem> | ||
<para>Parameter description for <tag>xsl:with-param</tag> <link | ||
xlink:href="https://www.w3schools.com/xml/ref_xsl_el_with-param.asp"/></para> | ||
</listitem> | ||
</itemizedlist> | ||
</section> | ||
</section> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rephrase it to "Inserting Graphics into Page Headers and Footer"?
Hmn, thinking about if "Logos" instead of "Graphics" would be more appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
New title is: "Inserting Logos into Page Headers and Footers"