DITA to PDF header issue - xslt-2.0

I have a dita XML with the following structure.
<bookmap>
<frontmatter><!-- FM content --></frontmatter>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
<concept><!-- chapter content --></concept>
</bookmap>
I need to have different header for only first page of first level the others are normal.
I used dita to pdf pluing static content for first page
<fo:static-content flow-name="first-body-header">
<fo:block xsl:use-attribute-sets="__body__odd__header">
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'Body odd header'"/>
<xsl:with-param name="params">
<!-- <prodname>
<xsl:value-of select="$productName"/>
</prodname>-->
<heading>
<fo:inline xsl:use-attribute-sets="__body__odd__header__heading">
<fo:retrieve-marker retrieve-class-name="current-header"/>
</fo:inline>
</heading>
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:static-content>
</xsl:template>
Unfortunately this template applies to all the first pages of all
parts.
Have anyone faced this issue before. I want this header to be applicable only first page of first level
Thanks in advance
Arul

I am not sure about dita, but this issue is #8.5 under (Apache's) XSL-FO FAQ, and can be achieved (with fo resources) by something like:
<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!-- layout master set: -->
<fo:layout-master-set>
<!-- page master for 1st page -->
<!-- define a (e.g.) A4 page-master with extra 20mm header region for the first page -->
<fo:simple-page-master master-name="myFirst"
page-height="297mm" page-width="210mm"
margin-top="20mm" margin-bottom="20mm"
margin-left="25mm" margin-right="25mm">
<fo:region-body margin-top="20mm"/>
<fo:region-before region-name="myHeaderFirst" extent="20mm"/>
<!-- define custom footer with <fo:region-after/> ... -->
</fo:simple-page-master>
<!-- page master for "rest" page (body only) -->
<fo:simple-page-master master-name="myRest"
page-height="297mm" page-width="210mm"
margin-top="20mm" margin-bottom="20mm"
margin-left="25mm" margin-right="25mm">
<!-- define only/same body -->
<fo:region-body/>
</fo:simple-page-master>
<!-- Da page seekwendz masta! ..combining myFirst and myRest ;) -->
<fo:page-sequence-master master-name="myDocument">
<fo:repeatable-page-master-alternatives>
<!-- here comes fo magic: "page-position" in (first|last|rest|any|only)
..with precedence! -->
<fo:conditional-page-master-reference page-position="first"
master-reference="myFirst"/>
<fo:conditional-page-master-reference page-position="rest"
master-reference="myRest"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<!-- here go the contents/page sequences ... -->
<fo:page-sequence master-reference="myDocument">
<!-- static content BEFORE flow! (a small pitfall,
esp. when it is the footer not the header:)) -->
<fo:static-content flow-name="myHeaderFirst">
TODO : "print" your header for first page here.
</fo:static-content>
<!-- define other/more static-contents ... -->
<fo:flow flow-name="xsl-region-body">
TODO : "print" flow/body.
<!-- xsl:applyTemplates /-->
</fo:flow>
</fo:page-sequence>
</fo:root>
https://xmlgraphics.apache.org/fop (apache's fo-impl home)
https://www.data2type.de/en/xml-xslt-xslfo/xsl-fo/ (very detailed documentation on xsl-fo in en + de language)

Related

facebook instant article sdk step by step in core php in localhost

How to implement facebook instant article sdk for php with localhost.I am using graph api to submit my article in facebook but i want to change my html to facebook instant article html automatically.
The only option for integration you will have for localhost dev environment setup will be the GraphAPI ingestion.
And still, you will need to claim URL to get content ingested to that particular page.
Example: yourdomain.com
You can create a dev.yourdomain.com and claim this just for your development environment.
Then you can create Instant Articles using the SDK and use as your canonical URL the dev.yourdomain.com.
Example:
<!doctype html>
<html lang="en" prefix="op: http://media.facebook.com/op#">
<head>
<meta charset="utf-8">
<!-- URL of the web version of this article -->
<link rel="canonical" href="http://dev.yourdomain.com/article.html">
<meta property="op:markup_version" content="v1.0">
</head>
<body>
<article>
<header>
<!-- The title and subtitle shown in your Instant Article -->
<h1>Article Title</h1>
<h2>Article Subtitle</h2>
<!-- The date and time when your article was originally published -->
<time class="op-published" datetime="2014-11-11T04:44:16Z">November 11th, 4:44 PM</time>
<!-- The date and time when your article was last updated -->
<time class="op-modified" dateTime="2014-12-11T04:44:16Z">December 11th, 4:44 PM</time>
<!-- The authors of your article -->
<address>
<a rel="facebook" href="http://facebook.com/brandon.diamond">Brandon Diamond</a>
Brandon is a avid zombie hunter.
</address>
<address>
<a>TR Vishwanath</a>
Vish is a scholar and a gentleman.
</address>
<!-- The cover image shown inside your article -->
<!-- TODO: Change the URL to a live image from your website -->
<figure>
<img src="http://example.com/path/to/img.jpg" />
<figcaption>This image is amazing</figcaption>
</figure>
<!-- A kicker for your article -->
<h3 class="op-kicker">
This is a kicker
</h3>
</header>
<!-- Article body goes here -->
<!-- Body text for your article -->
<p> Article content </p>
<!-- A video within your article -->
<!-- TODO: Change the URL to a live video from your website -->
<figure>
<video>
<source src="http://example.com/path/to/video.mp4" type="video/mp4" />
</video>
</figure>
<!-- An ad within your article -->
<!-- TODO: Change the URL to a live ad from your website -->
<figure class="op-ad">
<iframe src="https://www.example.com/ss;adtype=banner320x50" height="60" width="320"></iframe>
</figure>
<!-- Analytics code for your article -->
<figure class="op-tracker">
<iframe src="" hidden></iframe>
</figure>
<footer>
<!-- Credits for your article -->
<aside>Acknowledgements</aside>
<!-- Copyright details for your article -->
<small>Legal notes</small>
</footer>
</article>
</body>
</html>

Page Requires Multi Part, and presentation part Microsoft Graph API

I am trying to post a page to OneNote from the Microsoft Graph API, and when I enter in the section id that the page needs in order to post it throws me an error that states:
Page create requests require the content to be multipart, with a presentation part.
My Request header looks like this:
<!-- MyPartBoundary198374 -->
Content-Disposition:form-data; name="Presentation"
Content-Type:text/html
<!DOCTYPE html>
<html>
<head>
<title>A page with <i>rendered</i> images and an <b>attached</b> file</title>
<meta name="created" content="2015-07-22T09:00:00-08:00" />
</head>
<body>
<p>Here's an image from an online source:</p>
<img src="http://..." alt="an image on the page" width="500" />
<p>Here's an image uploaded as binary data:</p>
<img src="name:imageBlock1" alt="an image on the page" width="300" />
<p>Here's a file attachment:</p>
<object data-attachment="FileName.pdf" data="name:fileBlock1" type="application/pdf" />
</body>
</html>
<!-- MyPartBoundary198374 -->
Content-Disposition:form-data; name="imageBlock1"
Content-Type:image/jpeg
<!-- ... binary image data ... -->
<!-- MyPartBoundary198374 -->
Content-Disposition:form-data; name="fileBlock1"
Content-Type:application/pdf
<!-- ... binary file data ... -->
<!-- MyPartBoundary198374 -->
What could be the issue here?
You're missing the initial request:
POST https://graph.microsoft.com/v1.0/me/onenote/sections/{id}/pages
Content-length: 312
Content-type: multipart/form-data; boundary=MyPartBoundary198374

static mp3 song delayed starting with jplayer

I am trying to build a website that plays mp3. I am using:
jPlayer : For client side audio player.
icecast : For streaming mp3 audio.
Other technologies are ruby on rails, nginx, angularjs etc.
My Problem is:
jPlayer fully load the song then it start playing
So starting the song is always delayed based on song file size.
Other findings:
Byte rang request is working. But still loading the full song first.
My icecast.xml file is as following:
<icecast>
<!-- location and admin are two arbitrary strings that are e.g. visible
on the server info page of the icecast web interface
(server_version.xsl). -->
<location>Earth</location>
<admin>admin#playstore.com</admin>
<!-- IMPORTANT!
Especially for inexperienced users:
Start out by ONLY changing all passwords and restarting Icecast.
For detailed setup instructions please refer to the documentation.
It's also available here: http://icecast.org/docs/
-->
<limits>
<clients>100</clients>
<sources>2</sources>
<queue-size>2048</queue-size>
<client-timeout>30</client-timeout>
<header-timeout>15</header-timeout>
<source-timeout>10</source-timeout>
<!-- If enabled, this will provide a burst of data when a client
first connects, thereby significantly reducing the startup
time for listeners that do substantial buffering. However,
it also significantly increases latency between the source
client and listening client. For low-latency setups, you
might want to disable this. -->
<burst-on-connect>0</burst-on-connect>
<!-- same as burst-on-connect, but this allows for being more
specific on how much to burst. Most people won't need to
change from the default 64k. Applies to all mountpoints -->
<burst-size>512</burst-size>
</limits>
<authentication>
<!-- Sources log in with username 'source' -->
<source-password>irfan</source-password>
<!-- Relays log in with username 'relay' -->
<relay-password>passw0rd</relay-password>
<!-- Admin logs in with the username given below -->
<admin-user>admin</admin-user>
<admin-password>passw0rd</admin-password>
</authentication>
<!-- set the mountpoint for a shoutcast source to use, the default if not
specified is /stream but you can change it here if an alternative is
wanted or an extension is required
<shoutcast-mount>/live.nsv</shoutcast-mount>
-->
<!-- Uncomment this if you want directory listings -->
<!--
<directory>
<yp-url-timeout>15</yp-url-timeout>
<yp-url>http://dir.xiph.org/cgi-bin/yp-cgi</yp-url>
</directory>
-->
<!-- This is the hostname other people will use to connect to your server.
It affects mainly the urls generated by Icecast for playlists and yp
listings. You MUST configure it properly for YP listings to work!
-->
<hostname>localhost</hostname>
<!-- You may have multiple <listener> elements -->
<listen-socket>
<port>8000</port>
<bind-address>127.0.0.1</bind-address>
<shoutcast-mount>/stream</shoutcast-mount>
</listen-socket>
<!--
<listen-socket>
<port>8090</port>
</listen-socket>
-->
<!--
<listen-socket>
<port>8443</port>
<ssl>1</ssl>
</listen-socket>
-->
<!-- Global header settings
Headers defined here will be returned for every HTTP request to Icecast.
The ACAO header makes Icecast public content/API by default
This will make streams easier embeddable (some HTML5 functionality needs it).
Also it allows direct access to e.g. /status-json.xsl from other sites.
If you don't want this, comment out the following line or read up on CORS.
-->
<http-headers>
<header name="Access-Control-Allow-Origin" value="*" />
</http-headers>
<!-- Relaying
You don't need this if you only have one server.
Please refer to the config for a detailed explanation.
-->
<!--<master-server>127.0.0.1</master-server>-->
<!--<master-server-port>8001</master-server-port>-->
<!--<master-update-interval>120</master-update-interval>-->
<!--<master-password>hackme</master-password>-->
<!-- setting this makes all relays on-demand unless overridden, this is
useful for master relays which do not have <relay> definitions here.
The default is 0 -->
<!--<relays-on-demand>1</relays-on-demand>-->
<!--
<relay>
<server>127.0.0.1</server>
<port>8080</port>
<mount>/example.ogg</mount>
<local-mount>/different.ogg</local-mount>
<on-demand>0</on-demand>
<relay-shoutcast-metadata>0</relay-shoutcast-metadata>
</relay>
-->
<!-- Mountpoints
Only define <mount> sections if you want to use advanced options,
like alternative usernames or passwords
-->
<!-- Default settings for all mounts that don't have a specific <mount type="normal">.
-->
<!--
<mount type="default">
<public>0</public>
<intro>/server-wide-intro.ogg</intro>
<max-listener-duration>3600</max-listener-duration>
<authentication type="url">
<option name="mount_add" value="http://auth.example.org/stream_start.php"/>
</authentication>
<http-headers>
<header name="foo" value="bar" />
</http-headers>
</mount>
-->
<!-- Normal mounts -->
<!--
<mount type="normal">
<mount-name>/example-complex.ogg</mount-name>
<username>othersource</username>
<password>hackmemore</password>
<max-listeners>1</max-listeners>
<dump-file>/tmp/dump-example1.ogg</dump-file>
<burst-size>65536</burst-size>
<fallback-mount>/example2.ogg</fallback-mount>
<fallback-override>1</fallback-override>
<fallback-when-full>1</fallback-when-full>
<intro>/example_intro.ogg</intro>
<hidden>1</hidden>
<public>1</public>
<authentication type="htpasswd">
<option name="filename" value="myauth"/>
<option name="allow_duplicate_users" value="0"/>
</authentication>
<http-headers>
<header name="Access-Control-Allow-Origin" value="http://webplayer.example.org" />
<header name="baz" value="quux" />
</http-headers>
<on-connect>/home/icecast/bin/stream-start</on-connect>
<on-disconnect>/home/icecast/bin/stream-stop</on-disconnect>
</mount>
-->
<!--
<mount type="normal">
<mount-name>/auth_example.ogg</mount-name>
<authentication type="url">
<option name="mount_add" value="http://myauthserver.net/notify_mount.php"/>
<option name="mount_remove" value="http://myauthserver.net/notify_mount.php"/>
<option name="listener_add" value="http://myauthserver.net/notify_listener.php"/>
<option name="listener_remove" value="http://myauthserver.net/notify_listener.php"/>
<option name="headers" value="x-pragma,x-token"/>
<option name="header_prefix" value="ClientHeader."/>
</authentication>
</mount>
-->
<fileserve>1</fileserve>
<paths>
<!-- basedir is only used if chroot is enabled -->
<basedir>/usr/local/Cellar/icecast/2.4.2/share/icecast</basedir>
<!-- Note that if <chroot> is turned on below, these paths must both
be relative to the new root, not the original root -->
<logdir>/usr/local/Cellar/icecast/2.4.2/var/log/icecast</logdir>
<webroot>/usr/local/Cellar/icecast/2.4.2/share/icecast/web</webroot>
<adminroot>/usr/local/Cellar/icecast/2.4.2/share/icecast/admin</adminroot>
<!-- <pidfile>/usr/local/Cellar/icecast/2.4.2/share/icecast/icecast.pid</pidfile> -->
<!-- Aliases: treat requests for 'source' path as being for 'dest' path
May be made specific to a port or bound address using the "port"
and "bind-address" attributes.
-->
<!--
<alias source="/foo" destination="/bar"/>
-->
<!-- Aliases: can also be used for simple redirections as well,
this example will redirect all requests for http://server:port/ to
the status page
-->
<alias source="/" destination="/status.xsl"/>
<!-- The certificate file needs to contain both public and private part.
Both should be PEM encoded.
<ssl-certificate>/usr/local/Cellar/icecast/2.4.2/share/icecast/icecast.pem</ssl-certificate>
-->
</paths>
<logging>
<accesslog>access.log</accesslog>
<errorlog>error.log</errorlog>
<!-- <playlistlog>playlist.log</playlistlog> -->
<loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
<logsize>10000</logsize> <!-- Max size of a logfile -->
<!-- If logarchive is enabled (1), then when logsize is reached
the logfile will be moved to [error|access|playlist].log.DATESTAMP,
otherwise it will be moved to [error|access|playlist].log.old.
Default is non-archive mode (i.e. overwrite)
-->
<!-- <logarchive>1</logarchive> -->
</logging>
<security>
<chroot>0</chroot>
<!--
<changeowner>
<user>nobody</user>
<group>nogroup</group>
</changeowner>
-->
</security>
I need to understand how should I can do something that player will start playing the song after loading the very small amount of song to prevent starting delayed.
I finally solved it! I found chrome have the problem and it can't start an mp3 encoded music file while loading. But it can play immediately the other supported encoded music. Well this is not a permanent solution. But in my case, encoding all songs for fallback support gives me the trick. Now all major browsers are playing songs successfully.

Using Schematron QuickFixes to tag individual words in mixed content elements

I have an xml file that looks like this (simplifed):
<defs>
<def>Pure text</def>
<def>Mixed content, cuz there is also another: <element>element inside</element> and more.</def>
<def><element>Text nodes within elements other than def are ok.</element></def>
<defs>
I am trying to write a Shematron rule with quick fixes that would enable me to take each individual word in defs with mixed content and wrap them each in <w> elements as well as wrap punctuation characters in <pc> elements. In other words, after applying the quick fixes I would get
<defs>
<def>Pure text.</def>
<def><w>Mixed</w> <w>content</w><pc>,</pc> <w>cuz</w> <w>there</w> <w>is</w> <w>also</w> <w>another</w><pc>:</pc> <element>element inside</element> <w>and</w> <w>more</w><pc>.</pc></def>
<def><element>Text nodes within elements other than def are ok.</element></def>
<defs>
Spaces between <w>s and <pc>s are ok.
Now, identifying mixed content is easy — I think I am getting that right. The problem is I don't know how to tokenize the strings within Schematron and then apply a fix to each token. This is how far I've gotten:
<sch:pattern id="mixed">
<sch:rule context="def[child::text()][child::*]">
<sch:report test="tokenize(child::text(), '\s+')" sqf:fix="mix_in_def">
Element has mixed content
<!-- the above this gives me the error: a sequence of more than one item is not allowed as the first argument of tokenize-->
</sch:report>
<sqf:fix id="mix_in_def">
<sqf:description>
<sqf:title>Wrap words in w</sqf:title>
<sqf:p>Fixes the mixed content in def by treating each non-tagged string as w.</sqf:p>
</sqf:description>
<sqf:replace match="." node-type="element" target="w">
<!--how do i represent the content of the matched token?-->
</sqf:replace>
<!-- also do i create an altogether separate rule for punctuation?-->
</sqf:fix>
</sch:rule>
</sch:pattern>
Any tips would be greatly appreciated.
Tench
You can use XSL, look at this example (it is explained in code comments):
<sch:pattern id="mixed">
<!-- Your context is now def => this makes easier add new def reports -->
<sch:rule context="def">
<!-- So now you report every def that has text and elements -->
<sch:report test="child::text() and child::*" sqf:fix="mix_in_def">
Element has mixed content
<!-- What you were doing before where causing error because you were passing a sequence of text nodes to tokenize (it expects a string) -->
</sch:report>
<sqf:fix id="mix_in_def">
<sqf:description>
<sqf:title>Wrap words in w</sqf:title>
<sqf:p>Fixes the mixed content in def by treating each non-tagged string as w.</sqf:p>
</sqf:description>
<!-- Replace every mixed text node of this def (this is called for every matched node) -->
<sqf:replace match="child::text()">
<!-- Tokenize this text node => for each token choose... -->
<xsl:for-each select="tokenize(., '\s+')">
<!-- For this token choose -->
<xsl:choose>
<!-- If text is one of this (,.:) Please note that you are using \s+ to separate tokens. So a comma is only a token if it is separated by spaces -->
<xsl:when test=". = (',', '.', ':', 'is')"> <!-- "is" just to test results -->
<pc><xsl:value-of select="."/></pc>
</xsl:when>
<!-- Otherwise wrap it in <w> -->
<xsl:otherwise>
<w><xsl:value-of select="."/></w>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</sqf:replace>
</sqf:fix>
</sch:rule>
</sch:pattern>
You'll have to adapt this to your specific problem but I think this will help you.

Grails GSP outer templates with inner content?

Is there a way in Grails GSP to replace the following
<tmpl:/templates/header />
<!-- tmpl namespace call is equivalent to <g:render template="/templates/header" /> -->
<!-- definition of inner content -->
<tmpl:/templates/footer />
With an outer template? Essentially, a way to import the wrapping outer template,
<outertemplate:templatename>
<!-- header will be rendered from outer template -->
<!-- definition of inner content -->
<!-- footer will be rendered from outer template -->
</outertemplate:templatename>
and the definition of the outer template being something along the lines of
<!-- definition of header content -->
<!-- placeholder or attr for inner content -->
<!-- definition of footer content -->
Encapsulating the wrapping content in a single template versus two. IIRC there was a way to do this under JSF but I can't find an equivalent under GSP.
Ok so what I was looking for was Grails' SiteMesh layout support, which allows me to define commonly used view markup in a more eloquent manner then templates.
So the header and footer content can be placed inside a layout
<html>
<head>
<title><g:layoutTitle/></title>
<g:layoutHead />
</head>
<body>
<!-- HEADER CONTENT DEFINED HERE (or for stuff in head in the head above -->
<g:layoutBody />
<!-- FOOTER CONTENT DEFINED HERE -->
</body>
</html>
And then use the layout,
<html>
<head>
<title>An Example Page</title>
<meta name="layout" content="main" />
</head>
<body>This is my content!</body>
</html>
Which I think is much cleaner then header and footer templates.
You can also nest layouts.
You can create something like this using a tag library.
class SimpleTagLib {
def emoticon = { attrs, body ->
out << body() << (attrs.happy == 'true' ? " :-)" : " :-(")
}
}
This defines a tag emoticon that can be used in gsp like this:
<g:emoticon happy="true">Hi John</g:emoticon>
body() is used to render the tag body content.
(The example is copied from the offical grails documentation)

Resources