XSLT and wkhtmltopdf TOC Applying Different Templates to Item at Different DepthHow to apply an XSLT Stylesheet in C#XSLT - Adding Elements dynamicallyXSLT apply-template questionXSLT apply templates in different order of xml readingxslt apply template and matchapply template in xslt is not workingwkhtmltopdf - adding a sidebar that follows a span of varying textXSLT Template not being appliedpython-pdfkit (wkhtmltopdf) TOC overflowwkhtmltopdf: Custom order TOC
Decision tree nodes overlapping with Tikz
Why doesn't H₄O²⁺ exist?
How do I deal with an unproductive colleague in a small company?
Can you really stack all of this on an Opportunity Attack?
I'm flying to France today and my passport expires in less than 2 months
Important Resources for Dark Age Civilizations?
Modeling an IP Address
Mortgage Pre-approval / Loan - Apply Alone or with Fiancée?
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
Why is 150k or 200k jobs considered good when there's 300k+ births a month?
Can I make popcorn with any corn?
When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?
What is the word for reserving something for yourself before others do?
Can I ask the recruiters in my resume to put the reason why I am rejected?
Is it unprofessional to ask if a job posting on GlassDoor is real?
meaning of に in 本当に?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
Which country benefited the most from UN Security Council vetoes?
dbcc cleantable batch size explanation
Uncaught TypeError: 'set' on proxy: trap returned falsish for property Name
Question on branch cuts and branch points
Today is the Center
Why is Minecraft giving an OpenGL error?
Maximum likelihood parameters deviate from posterior distributions
XSLT and wkhtmltopdf TOC Applying Different Templates to Item at Different Depth
How to apply an XSLT Stylesheet in C#XSLT - Adding Elements dynamicallyXSLT apply-template questionXSLT apply templates in different order of xml readingxslt apply template and matchapply template in xslt is not workingwkhtmltopdf - adding a sidebar that follows a span of varying textXSLT Template not being appliedpython-pdfkit (wkhtmltopdf) TOC overflowwkhtmltopdf: Custom order TOC
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to loop through items inside of items in the TOC outline generated by wkhtmltopdf and apply a different style to each one.
One thing I've tried is the following with 3 different templates:
<xsl:template match="outline:outline">
<xsl:apply-templates select="outline:item/outline:item"/>
</xsl:template>
<xsl:template match="outline:item/outline:item">
<xsl:if test="((@title!='') and (@title!='Table of Contents'))">
<div style="width: 30%;">
<h1> <xsl:value-of select="@title" /> </h1>
</div>
<div style="width: 70%;">
<xsl:apply-templates select="outline:item"/>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="outline:item/outline:item/outline:item">
<h2> <xsl:value-of select="@title" /> </h2>
<ul class="leaders">
<xsl:apply-templates select="outline:item"/>
</ul>
</xsl:template>
<xsl:template match="outline:item/outline:item/outline:item/outline:item">
<li>
<h3>
<a>
<xsl:if test="@link">
<xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute>
</xsl:if>
<xsl:if test="@backLink">
<xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute>
</xsl:if>
<span> <xsl:value-of select="@title" /> </span>
<span> <xsl:value-of select="@page" /> </span>
</a>
</h3>
</li>
</xsl:template>
I've also tried applying the templates by mode, or other things. Another one that I've tried is using 3 <xsl:for-each> inside each other. As a reference, this is an example of the xml that's generated by wkhtmltopdf.
<?xml version="1.0" encoding="UTF-8"?>
<outline xmlns="http://wkhtmltopdf.org/outline">
<item title="" page="0" link="" backLink=""/>
<item title="" page="1" link="__WKANCHOR_0" backLink="__WKANCHOR_1">
<item title="Table of Contents" page="3" link="__WKANCHOR_2" backLink="__WKANCHOR_3">
<item title="H2 Test" page="3" link="test" backLink="test">
<item title="H3 Test" page="3" link="test" backLink="test"/>
</item>
</item>
<item title="Example Page 1" page="4" link="__WKANCHOR_4" backLink="__WKANCHOR_5"/>
<item title="Example Page 2" page="5" link="__WKANCHOR_6" backLink="__WKANCHOR_7"/>
</item>
</outline>
MY QUESTION: What's the right way to do this and get it to work with wkhtmltopdf? So far, with wkhtmltopdf I'm not getting any output for that part of the TOC page. With my own XSLT parser, I'm only getting the <h1> output and nothing else. How can I fix this?
EDIT
As per request, this is an example of the desired output. It's super simplified, and so is the above code, but in general this is kind of what I want it to look like, with proper fonts and other styling.
<html>
<head>
<style>
body
margin: 0 1in;
ul
list-style: none;
margin: 0;
padding: 0;
overflow-x: hidden;
ul.leaders li:before
float: left;
width: 0;
white-space: nowrap;
color: #003963;
font-size: 1.6rem;
content:
"........................................"
"........................................"
"........................................"
"........................................"
"........................................";
ul.leaders span:first-child
padding-right: 0.33em;
background: white;
ul.leaders span + span
float: right;
padding-left: 0.33em;
background: white;
position: relative;
z-index: 10;
font-size: 1rem;
ul.leaders span
margin-top: 0.5rem;
h1
text-align: center;
color: #96D1F2;
h2
color: #F15A22;
h3
color: #003963;
text-transform: uppercase;
</style>
</head>
<body>
<div>
<div style="width: 30%; float: left; display: inline-block;">
<h1>Big section</h1>
</div>
<div style="width: 70%; float: right; display: inline-block;">
<h2>Sorta Big section</h2>
<ul class="leaders">
<li>
<h3>
<span>Smaller Section</span>
<span>2</span>
</h3>
</li>
<li>
<h3>
<span>Smaller Section 2</span>
<span>3</span>
</h3>
</li>
<li>
<h3>
<span>Smaller Section 3</span>
<span>4</span>
</h3>
</li>
</ul>
</div>
</div>
</body>
</html>
EDIT 2:
I've made the update suggested in the answer below and it fixed it for my parser in IntelliJ IDEA (my IDE), but it still has the same problem as it did in wkhtmltopdf where it just hangs once it hits the TOC stage.
xml xslt wkhtmltopdf
add a comment |
I'm trying to loop through items inside of items in the TOC outline generated by wkhtmltopdf and apply a different style to each one.
One thing I've tried is the following with 3 different templates:
<xsl:template match="outline:outline">
<xsl:apply-templates select="outline:item/outline:item"/>
</xsl:template>
<xsl:template match="outline:item/outline:item">
<xsl:if test="((@title!='') and (@title!='Table of Contents'))">
<div style="width: 30%;">
<h1> <xsl:value-of select="@title" /> </h1>
</div>
<div style="width: 70%;">
<xsl:apply-templates select="outline:item"/>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="outline:item/outline:item/outline:item">
<h2> <xsl:value-of select="@title" /> </h2>
<ul class="leaders">
<xsl:apply-templates select="outline:item"/>
</ul>
</xsl:template>
<xsl:template match="outline:item/outline:item/outline:item/outline:item">
<li>
<h3>
<a>
<xsl:if test="@link">
<xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute>
</xsl:if>
<xsl:if test="@backLink">
<xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute>
</xsl:if>
<span> <xsl:value-of select="@title" /> </span>
<span> <xsl:value-of select="@page" /> </span>
</a>
</h3>
</li>
</xsl:template>
I've also tried applying the templates by mode, or other things. Another one that I've tried is using 3 <xsl:for-each> inside each other. As a reference, this is an example of the xml that's generated by wkhtmltopdf.
<?xml version="1.0" encoding="UTF-8"?>
<outline xmlns="http://wkhtmltopdf.org/outline">
<item title="" page="0" link="" backLink=""/>
<item title="" page="1" link="__WKANCHOR_0" backLink="__WKANCHOR_1">
<item title="Table of Contents" page="3" link="__WKANCHOR_2" backLink="__WKANCHOR_3">
<item title="H2 Test" page="3" link="test" backLink="test">
<item title="H3 Test" page="3" link="test" backLink="test"/>
</item>
</item>
<item title="Example Page 1" page="4" link="__WKANCHOR_4" backLink="__WKANCHOR_5"/>
<item title="Example Page 2" page="5" link="__WKANCHOR_6" backLink="__WKANCHOR_7"/>
</item>
</outline>
MY QUESTION: What's the right way to do this and get it to work with wkhtmltopdf? So far, with wkhtmltopdf I'm not getting any output for that part of the TOC page. With my own XSLT parser, I'm only getting the <h1> output and nothing else. How can I fix this?
EDIT
As per request, this is an example of the desired output. It's super simplified, and so is the above code, but in general this is kind of what I want it to look like, with proper fonts and other styling.
<html>
<head>
<style>
body
margin: 0 1in;
ul
list-style: none;
margin: 0;
padding: 0;
overflow-x: hidden;
ul.leaders li:before
float: left;
width: 0;
white-space: nowrap;
color: #003963;
font-size: 1.6rem;
content:
"........................................"
"........................................"
"........................................"
"........................................"
"........................................";
ul.leaders span:first-child
padding-right: 0.33em;
background: white;
ul.leaders span + span
float: right;
padding-left: 0.33em;
background: white;
position: relative;
z-index: 10;
font-size: 1rem;
ul.leaders span
margin-top: 0.5rem;
h1
text-align: center;
color: #96D1F2;
h2
color: #F15A22;
h3
color: #003963;
text-transform: uppercase;
</style>
</head>
<body>
<div>
<div style="width: 30%; float: left; display: inline-block;">
<h1>Big section</h1>
</div>
<div style="width: 70%; float: right; display: inline-block;">
<h2>Sorta Big section</h2>
<ul class="leaders">
<li>
<h3>
<span>Smaller Section</span>
<span>2</span>
</h3>
</li>
<li>
<h3>
<span>Smaller Section 2</span>
<span>3</span>
</h3>
</li>
<li>
<h3>
<span>Smaller Section 3</span>
<span>4</span>
</h3>
</li>
</ul>
</div>
</div>
</body>
</html>
EDIT 2:
I've made the update suggested in the answer below and it fixed it for my parser in IntelliJ IDEA (my IDE), but it still has the same problem as it did in wkhtmltopdf where it just hangs once it hits the TOC stage.
xml xslt wkhtmltopdf
What would your desired XML output look like? And what XSLT version can you use?
– zx485
Mar 21 at 22:52
I've tried to figure out what XSLT version wkhtmltopdf uses, and the best I can find is that it's using QTWebKit to do the whole thing. I've tried to figure out if there is some sort of reference about that, but I can't find it. As for the XML output, I'm editing my question with an example.
– Ethan Brouwer
Mar 21 at 22:58
If you cannot find any information, it'd be safest to assume version 1.0. But the priority should be on the desired outcome.
– zx485
Mar 21 at 22:59
"MY QUESTION: What's the right way to do this and get it to happen?" I think you need to refrase that.
– Alejandro
Mar 22 at 15:20
add a comment |
I'm trying to loop through items inside of items in the TOC outline generated by wkhtmltopdf and apply a different style to each one.
One thing I've tried is the following with 3 different templates:
<xsl:template match="outline:outline">
<xsl:apply-templates select="outline:item/outline:item"/>
</xsl:template>
<xsl:template match="outline:item/outline:item">
<xsl:if test="((@title!='') and (@title!='Table of Contents'))">
<div style="width: 30%;">
<h1> <xsl:value-of select="@title" /> </h1>
</div>
<div style="width: 70%;">
<xsl:apply-templates select="outline:item"/>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="outline:item/outline:item/outline:item">
<h2> <xsl:value-of select="@title" /> </h2>
<ul class="leaders">
<xsl:apply-templates select="outline:item"/>
</ul>
</xsl:template>
<xsl:template match="outline:item/outline:item/outline:item/outline:item">
<li>
<h3>
<a>
<xsl:if test="@link">
<xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute>
</xsl:if>
<xsl:if test="@backLink">
<xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute>
</xsl:if>
<span> <xsl:value-of select="@title" /> </span>
<span> <xsl:value-of select="@page" /> </span>
</a>
</h3>
</li>
</xsl:template>
I've also tried applying the templates by mode, or other things. Another one that I've tried is using 3 <xsl:for-each> inside each other. As a reference, this is an example of the xml that's generated by wkhtmltopdf.
<?xml version="1.0" encoding="UTF-8"?>
<outline xmlns="http://wkhtmltopdf.org/outline">
<item title="" page="0" link="" backLink=""/>
<item title="" page="1" link="__WKANCHOR_0" backLink="__WKANCHOR_1">
<item title="Table of Contents" page="3" link="__WKANCHOR_2" backLink="__WKANCHOR_3">
<item title="H2 Test" page="3" link="test" backLink="test">
<item title="H3 Test" page="3" link="test" backLink="test"/>
</item>
</item>
<item title="Example Page 1" page="4" link="__WKANCHOR_4" backLink="__WKANCHOR_5"/>
<item title="Example Page 2" page="5" link="__WKANCHOR_6" backLink="__WKANCHOR_7"/>
</item>
</outline>
MY QUESTION: What's the right way to do this and get it to work with wkhtmltopdf? So far, with wkhtmltopdf I'm not getting any output for that part of the TOC page. With my own XSLT parser, I'm only getting the <h1> output and nothing else. How can I fix this?
EDIT
As per request, this is an example of the desired output. It's super simplified, and so is the above code, but in general this is kind of what I want it to look like, with proper fonts and other styling.
<html>
<head>
<style>
body
margin: 0 1in;
ul
list-style: none;
margin: 0;
padding: 0;
overflow-x: hidden;
ul.leaders li:before
float: left;
width: 0;
white-space: nowrap;
color: #003963;
font-size: 1.6rem;
content:
"........................................"
"........................................"
"........................................"
"........................................"
"........................................";
ul.leaders span:first-child
padding-right: 0.33em;
background: white;
ul.leaders span + span
float: right;
padding-left: 0.33em;
background: white;
position: relative;
z-index: 10;
font-size: 1rem;
ul.leaders span
margin-top: 0.5rem;
h1
text-align: center;
color: #96D1F2;
h2
color: #F15A22;
h3
color: #003963;
text-transform: uppercase;
</style>
</head>
<body>
<div>
<div style="width: 30%; float: left; display: inline-block;">
<h1>Big section</h1>
</div>
<div style="width: 70%; float: right; display: inline-block;">
<h2>Sorta Big section</h2>
<ul class="leaders">
<li>
<h3>
<span>Smaller Section</span>
<span>2</span>
</h3>
</li>
<li>
<h3>
<span>Smaller Section 2</span>
<span>3</span>
</h3>
</li>
<li>
<h3>
<span>Smaller Section 3</span>
<span>4</span>
</h3>
</li>
</ul>
</div>
</div>
</body>
</html>
EDIT 2:
I've made the update suggested in the answer below and it fixed it for my parser in IntelliJ IDEA (my IDE), but it still has the same problem as it did in wkhtmltopdf where it just hangs once it hits the TOC stage.
xml xslt wkhtmltopdf
I'm trying to loop through items inside of items in the TOC outline generated by wkhtmltopdf and apply a different style to each one.
One thing I've tried is the following with 3 different templates:
<xsl:template match="outline:outline">
<xsl:apply-templates select="outline:item/outline:item"/>
</xsl:template>
<xsl:template match="outline:item/outline:item">
<xsl:if test="((@title!='') and (@title!='Table of Contents'))">
<div style="width: 30%;">
<h1> <xsl:value-of select="@title" /> </h1>
</div>
<div style="width: 70%;">
<xsl:apply-templates select="outline:item"/>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="outline:item/outline:item/outline:item">
<h2> <xsl:value-of select="@title" /> </h2>
<ul class="leaders">
<xsl:apply-templates select="outline:item"/>
</ul>
</xsl:template>
<xsl:template match="outline:item/outline:item/outline:item/outline:item">
<li>
<h3>
<a>
<xsl:if test="@link">
<xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute>
</xsl:if>
<xsl:if test="@backLink">
<xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute>
</xsl:if>
<span> <xsl:value-of select="@title" /> </span>
<span> <xsl:value-of select="@page" /> </span>
</a>
</h3>
</li>
</xsl:template>
I've also tried applying the templates by mode, or other things. Another one that I've tried is using 3 <xsl:for-each> inside each other. As a reference, this is an example of the xml that's generated by wkhtmltopdf.
<?xml version="1.0" encoding="UTF-8"?>
<outline xmlns="http://wkhtmltopdf.org/outline">
<item title="" page="0" link="" backLink=""/>
<item title="" page="1" link="__WKANCHOR_0" backLink="__WKANCHOR_1">
<item title="Table of Contents" page="3" link="__WKANCHOR_2" backLink="__WKANCHOR_3">
<item title="H2 Test" page="3" link="test" backLink="test">
<item title="H3 Test" page="3" link="test" backLink="test"/>
</item>
</item>
<item title="Example Page 1" page="4" link="__WKANCHOR_4" backLink="__WKANCHOR_5"/>
<item title="Example Page 2" page="5" link="__WKANCHOR_6" backLink="__WKANCHOR_7"/>
</item>
</outline>
MY QUESTION: What's the right way to do this and get it to work with wkhtmltopdf? So far, with wkhtmltopdf I'm not getting any output for that part of the TOC page. With my own XSLT parser, I'm only getting the <h1> output and nothing else. How can I fix this?
EDIT
As per request, this is an example of the desired output. It's super simplified, and so is the above code, but in general this is kind of what I want it to look like, with proper fonts and other styling.
<html>
<head>
<style>
body
margin: 0 1in;
ul
list-style: none;
margin: 0;
padding: 0;
overflow-x: hidden;
ul.leaders li:before
float: left;
width: 0;
white-space: nowrap;
color: #003963;
font-size: 1.6rem;
content:
"........................................"
"........................................"
"........................................"
"........................................"
"........................................";
ul.leaders span:first-child
padding-right: 0.33em;
background: white;
ul.leaders span + span
float: right;
padding-left: 0.33em;
background: white;
position: relative;
z-index: 10;
font-size: 1rem;
ul.leaders span
margin-top: 0.5rem;
h1
text-align: center;
color: #96D1F2;
h2
color: #F15A22;
h3
color: #003963;
text-transform: uppercase;
</style>
</head>
<body>
<div>
<div style="width: 30%; float: left; display: inline-block;">
<h1>Big section</h1>
</div>
<div style="width: 70%; float: right; display: inline-block;">
<h2>Sorta Big section</h2>
<ul class="leaders">
<li>
<h3>
<span>Smaller Section</span>
<span>2</span>
</h3>
</li>
<li>
<h3>
<span>Smaller Section 2</span>
<span>3</span>
</h3>
</li>
<li>
<h3>
<span>Smaller Section 3</span>
<span>4</span>
</h3>
</li>
</ul>
</div>
</div>
</body>
</html>
EDIT 2:
I've made the update suggested in the answer below and it fixed it for my parser in IntelliJ IDEA (my IDE), but it still has the same problem as it did in wkhtmltopdf where it just hangs once it hits the TOC stage.
xml xslt wkhtmltopdf
xml xslt wkhtmltopdf
edited Mar 22 at 20:26
Ethan Brouwer
asked Mar 21 at 22:44
Ethan BrouwerEthan Brouwer
513425
513425
What would your desired XML output look like? And what XSLT version can you use?
– zx485
Mar 21 at 22:52
I've tried to figure out what XSLT version wkhtmltopdf uses, and the best I can find is that it's using QTWebKit to do the whole thing. I've tried to figure out if there is some sort of reference about that, but I can't find it. As for the XML output, I'm editing my question with an example.
– Ethan Brouwer
Mar 21 at 22:58
If you cannot find any information, it'd be safest to assume version 1.0. But the priority should be on the desired outcome.
– zx485
Mar 21 at 22:59
"MY QUESTION: What's the right way to do this and get it to happen?" I think you need to refrase that.
– Alejandro
Mar 22 at 15:20
add a comment |
What would your desired XML output look like? And what XSLT version can you use?
– zx485
Mar 21 at 22:52
I've tried to figure out what XSLT version wkhtmltopdf uses, and the best I can find is that it's using QTWebKit to do the whole thing. I've tried to figure out if there is some sort of reference about that, but I can't find it. As for the XML output, I'm editing my question with an example.
– Ethan Brouwer
Mar 21 at 22:58
If you cannot find any information, it'd be safest to assume version 1.0. But the priority should be on the desired outcome.
– zx485
Mar 21 at 22:59
"MY QUESTION: What's the right way to do this and get it to happen?" I think you need to refrase that.
– Alejandro
Mar 22 at 15:20
What would your desired XML output look like? And what XSLT version can you use?
– zx485
Mar 21 at 22:52
What would your desired XML output look like? And what XSLT version can you use?
– zx485
Mar 21 at 22:52
I've tried to figure out what XSLT version wkhtmltopdf uses, and the best I can find is that it's using QTWebKit to do the whole thing. I've tried to figure out if there is some sort of reference about that, but I can't find it. As for the XML output, I'm editing my question with an example.
– Ethan Brouwer
Mar 21 at 22:58
I've tried to figure out what XSLT version wkhtmltopdf uses, and the best I can find is that it's using QTWebKit to do the whole thing. I've tried to figure out if there is some sort of reference about that, but I can't find it. As for the XML output, I'm editing my question with an example.
– Ethan Brouwer
Mar 21 at 22:58
If you cannot find any information, it'd be safest to assume version 1.0. But the priority should be on the desired outcome.
– zx485
Mar 21 at 22:59
If you cannot find any information, it'd be safest to assume version 1.0. But the priority should be on the desired outcome.
– zx485
Mar 21 at 22:59
"MY QUESTION: What's the right way to do this and get it to happen?" I think you need to refrase that.
– Alejandro
Mar 22 at 15:20
"MY QUESTION: What's the right way to do this and get it to happen?" I think you need to refrase that.
– Alejandro
Mar 22 at 15:20
add a comment |
1 Answer
1
active
oldest
votes
You should change your xsl:if in the second template from
<xsl:if test="((@title!='') and (@title!='Table of Contents'))">
to
<xsl:if test="@title!=''">
Then your output changes to
<div style="width: 30%;">
<h1>Table of Contents</h1>
</div>
<div style="width: 70%;">
<h2 xmlns:outline="http://wkhtmltopdf.org/outline">H2 Test</h2>
<ul xmlns:outline="http://wkhtmltopdf.org/outline" class="leaders">
<li>
<h3>
<a href="test" name="test">
<span>H3 Test</span>
<span>3</span>
</a>
</h3>
</li>
</ul>
</div>
<div style="width: 30%;">
<h1>Example Page 1</h1>
</div>
<div style="width: 70%;"/>
<div style="width: 30%;">
<h1>Example Page 2</h1>
</div>
<div style="width: 70%;"/>
which is pretty close to the desired outcome.
I couldn't improve the templates further, because your desired outcome differs too extensive. But I guess that you now can get along.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290332%2fxslt-and-wkhtmltopdf-toc-applying-different-templates-to-item-at-different-depth%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should change your xsl:if in the second template from
<xsl:if test="((@title!='') and (@title!='Table of Contents'))">
to
<xsl:if test="@title!=''">
Then your output changes to
<div style="width: 30%;">
<h1>Table of Contents</h1>
</div>
<div style="width: 70%;">
<h2 xmlns:outline="http://wkhtmltopdf.org/outline">H2 Test</h2>
<ul xmlns:outline="http://wkhtmltopdf.org/outline" class="leaders">
<li>
<h3>
<a href="test" name="test">
<span>H3 Test</span>
<span>3</span>
</a>
</h3>
</li>
</ul>
</div>
<div style="width: 30%;">
<h1>Example Page 1</h1>
</div>
<div style="width: 70%;"/>
<div style="width: 30%;">
<h1>Example Page 2</h1>
</div>
<div style="width: 70%;"/>
which is pretty close to the desired outcome.
I couldn't improve the templates further, because your desired outcome differs too extensive. But I guess that you now can get along.
add a comment |
You should change your xsl:if in the second template from
<xsl:if test="((@title!='') and (@title!='Table of Contents'))">
to
<xsl:if test="@title!=''">
Then your output changes to
<div style="width: 30%;">
<h1>Table of Contents</h1>
</div>
<div style="width: 70%;">
<h2 xmlns:outline="http://wkhtmltopdf.org/outline">H2 Test</h2>
<ul xmlns:outline="http://wkhtmltopdf.org/outline" class="leaders">
<li>
<h3>
<a href="test" name="test">
<span>H3 Test</span>
<span>3</span>
</a>
</h3>
</li>
</ul>
</div>
<div style="width: 30%;">
<h1>Example Page 1</h1>
</div>
<div style="width: 70%;"/>
<div style="width: 30%;">
<h1>Example Page 2</h1>
</div>
<div style="width: 70%;"/>
which is pretty close to the desired outcome.
I couldn't improve the templates further, because your desired outcome differs too extensive. But I guess that you now can get along.
add a comment |
You should change your xsl:if in the second template from
<xsl:if test="((@title!='') and (@title!='Table of Contents'))">
to
<xsl:if test="@title!=''">
Then your output changes to
<div style="width: 30%;">
<h1>Table of Contents</h1>
</div>
<div style="width: 70%;">
<h2 xmlns:outline="http://wkhtmltopdf.org/outline">H2 Test</h2>
<ul xmlns:outline="http://wkhtmltopdf.org/outline" class="leaders">
<li>
<h3>
<a href="test" name="test">
<span>H3 Test</span>
<span>3</span>
</a>
</h3>
</li>
</ul>
</div>
<div style="width: 30%;">
<h1>Example Page 1</h1>
</div>
<div style="width: 70%;"/>
<div style="width: 30%;">
<h1>Example Page 2</h1>
</div>
<div style="width: 70%;"/>
which is pretty close to the desired outcome.
I couldn't improve the templates further, because your desired outcome differs too extensive. But I guess that you now can get along.
You should change your xsl:if in the second template from
<xsl:if test="((@title!='') and (@title!='Table of Contents'))">
to
<xsl:if test="@title!=''">
Then your output changes to
<div style="width: 30%;">
<h1>Table of Contents</h1>
</div>
<div style="width: 70%;">
<h2 xmlns:outline="http://wkhtmltopdf.org/outline">H2 Test</h2>
<ul xmlns:outline="http://wkhtmltopdf.org/outline" class="leaders">
<li>
<h3>
<a href="test" name="test">
<span>H3 Test</span>
<span>3</span>
</a>
</h3>
</li>
</ul>
</div>
<div style="width: 30%;">
<h1>Example Page 1</h1>
</div>
<div style="width: 70%;"/>
<div style="width: 30%;">
<h1>Example Page 2</h1>
</div>
<div style="width: 70%;"/>
which is pretty close to the desired outcome.
I couldn't improve the templates further, because your desired outcome differs too extensive. But I guess that you now can get along.
answered Mar 21 at 23:20
zx485zx485
15.3k133248
15.3k133248
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290332%2fxslt-and-wkhtmltopdf-toc-applying-different-templates-to-item-at-different-depth%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What would your desired XML output look like? And what XSLT version can you use?
– zx485
Mar 21 at 22:52
I've tried to figure out what XSLT version wkhtmltopdf uses, and the best I can find is that it's using QTWebKit to do the whole thing. I've tried to figure out if there is some sort of reference about that, but I can't find it. As for the XML output, I'm editing my question with an example.
– Ethan Brouwer
Mar 21 at 22:58
If you cannot find any information, it'd be safest to assume version 1.0. But the priority should be on the desired outcome.
– zx485
Mar 21 at 22:59
"MY QUESTION: What's the right way to do this and get it to happen?" I think you need to refrase that.
– Alejandro
Mar 22 at 15:20