How to use XSL to make a href using XML data - nginx

I'm trying to create an XML file that shows different news articles within an iframe. A shortened version of the news' body is shown as a subtitle (which is already prewritten and chosen with the help of PHP, this isn't the issue) and to show the full body, the idea is to take the user to a link where the full body is shown. The PHP creates a file in the folder 'articles' on the root directory which contains the full body with the folder name as the title (e.g if the title was 'foo' then the xml file would be under: /articles/foo/index.xml (the XSL is already done for that file)).
My idea is to add a link to the XML with the shortened body to the XML page that would link to the file in the articles folder to allow a user to read the whole body. How would I, using the XSL stylesheet, create a link to this XML page with the whole body?
Below is the code for the XML and XSL to be used in the iframe (without the body)
XML code:
...
<articles>
<article>
<title>(This is what I want to be used as a link)</title>
<image></image>
<subtitle></subtitle>
</article>
</articles>
XSL code:
...
<table...>
<xsl:for-each select="articles/article">
<th...><img src="{image}"...></th>
<th...><h1><xsl:value-of select="title" /></h1></th>
</xsl:for-each>
</tr>
<tr>
<xsl:for-each select="articles/article">
<th...><h2><xsl:value-of select="subtitle" /></h2></th>
</xsl:for-each>
</tr>
</table>
...
I'm looking to set the XSL title part to a href to link to the mentioned page. How would I do this?

I figured this out by, in the XSL, doing the following:
...
<th...><h1><xsl:value-of select="title" /></h1></th>
...

Related

output raw javascript using handlebars

I created a mini CMS to store code snippets.
It pulls articles form a mongodb database.
I use highlgiht.js to display the code and allow users to copy the snippets.
With HTML, everything works as expected:
{{#article}}
<h1>Demo</h1>
{{{markup}}} <!-- prints raw HTML in the screen, yay! -->
<h1>HTML</h1>
<pre class="pre-scrollable"><code class="html">{{markup}}</code></pre>
<!-- prints escaped HTML in the screen, and highlight.js highlights it perfectly! YAY -->
{{/article}}
Now, with Javascript:
{{#article}}
<h1>Demo</h1>
{{{js}}} <!-- prints empty script tag: <script></script> -->
<h1>JS</h1>
<pre class="pre-scrollable"><code class="html">{{js}}</code></pre>
<!-- prints <script></script> -->
{{/article}}
The content of the field "js" in the database is "console.log("test");"
Why is it not outputting what's saved in the db, but instead it is making up a new script tag on its own??
Thank you!
After pulling most of my hair, I figured it out:
I had a name collision where my document property/field was named "js" and that conflicted with the name of a helper from a library I am using:
https://github.com/helpers/handlebars-helpers/blob/master/lib/html.js#L85

display xml file in browser with asp.net

This may be simple, although i'm having some trouble finding a solution.
i create a sitemap for my website in an xml file.i display content of xml file in aspx file.
but i want display xmlfile not in aspx.
when i use response.redirect("sitemap.xml"),it shows tree but i want to show only all content in sequential not in tree.
like this:
content of xmlfile:
<t><t1 p="s1"></t1><t2 p="s2"></t2></t>
but i want address bar=sitemap.xml and show like this:
p=s1p=s2 .....
any idea?
Some browsers will respect XSL declarations at the top of xml files. If you have such a declaration at the top of your xml file like this:
<?xml-stylesheet type="text/xsl" href="YourTransform.xsl"?>
It will apply the transform specified allowing you to output the xml however you want. However, support is not universal.

Inlcuding Html code within Html

Suppose I have 3 html files , A.html , B.html and C.html
I want the HTML code from C.html to act as the footer of A.html and B.html .
Currently what I do is write the total contents of C.html in A & B to have my footer.
Is it possible to use just a single code or css-stlye to load the contents of C.html
Suppose C.html looks like --
<a href=k.com>K</a><br>
<a href=b.com>b</a><br>
<a href=d.com>d</a><br>
<b>This page made by me</b>
How to have this code inserted to other files just by using a single code.
Please note that I have seen this Include another HTML file in a HTML file page but the codes seem to not work for me. I can use <iframe> but then it doesn't look pretty.
If your server supports any server side language (as most web servers does)
then you can easily marge files.
// Example in php.
<?php
include "a.html";
include "b.html";
include "c.html";
?>
In pure HTML it is not possible. Why not use an iFrame? You can then style it as you choose.
Or you can use jQuery's load method to pull content into your page.
Or use a language like PHP to include html parts

Embed Code in Drupal

I am not familiar with Drupal but our clients report that what we provide as embed isn't working with drupal.
Our embed code will be
<iframe id="ivideoframe" src="https://mywebsite/Player.aspx?q=IsahXh4JBPTq9sc%252b2j4zmaJvfFIagPpqAIBQIZpQTGUxPzzL8g44uVrsRGGRbDnSk5IO3kBeGI%252b211on7BfXBL6UjrXe%252fI%252bhftSaavtHay8%253d" height="419" width="665" toolbar="no" scrolling="no" frameborder="0"></iframe>
What I understand from client is the query string letter "?q" has some issue with drupal. Can some one help me to understand how this code will result in error when used in drupal?
If you are putting this embedded code into a block, or a CCK field of some sort (body, text, etc), you'll want to make sure that the "Text Format" is set to either Full HTML or one that allow the use of full html.
Even Full HTML can sometimes be buggy with iFrame's, I've found. We've found the best practice is to actually create your own Text Format called "Raw HTML" that allows everything and doesn't try to format things at all. You can create it at [Admin --> Configuration --> Content authoring --> Text Formats].
Then once you've created the format, simply choose that custom format on the field that contains the iFrame embed code.

XSLT - unmapped fields at bottom of html

I have an XML document which references a XSL file for the output of HTML.
In the XSL file I have put in various "<xsl:value-of select="fieldname" />" tags referencing items in my XML File.
However for the items I have not mapped they just appear as a long string at the bottom of the html page?
Do I really need to omit all my xml data items not referenced in the XSL file for them to go away or is there a trick to this or a bug in my XSL file?
j
This is result of the XSLT Processing Model.
XSLT uses its *built-in templates` if a node should be processed and no template in the XSLT code is matching it. The built-in template that matches a text node copies it.
Solution:
Add this template that overrides the XSLT built-in template for text nodes:
<xsl:template match="text()"/>
This causes any text node not matched by a more specific template in the code (and not copied with xsl:copy-of or xsl:value-of) to be ignored ("deleted").

Resources