Created
December 22, 2011 17:00
-
-
Save nils-werner/1510998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<html> | |
<head> | |
<link rel="stylesheet" href="workspace/assets/style.css"/> | |
</head> | |
<body> | |
<div id="head"> | |
<h1>Title</h1> | |
</div> | |
<div id="package"> | |
<div id="content"> | |
<h2>Blog</h2> | |
<div datasource="blog-articles"> | |
<div class="article"> | |
<h3 value="title">Title</h3> | |
<p copy="body"> | |
Lorem Ipsum | |
</p> | |
</div> | |
</div> | |
<div id="comments"> | |
<h3>Comments</h3> | |
<div datasource="article-comments"> | |
<p value="text"> | |
Commenttext | |
</p> | |
</div> | |
</div> | |
<div id="sidebar"> | |
<h3> | |
All Articles | |
</h3> | |
<ul> | |
<div datasource="blog-article-index"> | |
<li value="title">Something</li> | |
</div> | |
</ul> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<x:stylesheet version="1.0" | |
xmlns:x="http://www.w3.org/1999/XSL/Transform" | |
xmlns:xsl="http://www.w3.org/1999/XSL/TransformAlias"> | |
<x:output method="xml" | |
encoding="UTF-8" | |
indent="yes" /> | |
<x:namespace-alias stylesheet-prefix="xsl" result-prefix="x"/> | |
<x:template match="*"> | |
<x:element name="{name()}"> | |
<x:apply-templates select="* | @* | text()" /> | |
</x:element> | |
</x:template> | |
<x:template match="@*"> | |
<x:attribute name="{name()}"> | |
<x:value-of select="."/> | |
</x:attribute> | |
</x:template> | |
<x:template match="@datasource | @value | @copy" /> | |
<x:template match="/"> | |
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/TransformAlias"> | |
<xsl:output method="xml" | |
encoding="UTF-8" | |
indent="yes" /> | |
<x:apply-templates /> | |
<x:apply-templates select="//*[@datasource]" mode="templates" /> | |
</xsl:stylesheet> | |
</x:template> | |
<x:template match="*[@datasource]"> | |
<xsl:apply-templates select="{@datasource}/entry" /> | |
</x:template> | |
<x:template match="*[@value]/text()"> | |
<xsl:value-of select="{../@value}" /> | |
</x:template> | |
<x:template match="*[@copy]"> | |
<xsl:copy-of select="{@copy}/*" /> | |
</x:template> | |
<x:template match="*[@datasource]" mode="templates"> | |
<x:text> | |
</x:text> | |
<xsl:template match="{@datasource}/entry"> | |
<x:apply-templates /> | |
</xsl:template> | |
</x:template> | |
</x:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To try this out simply download the code and run it using
The returned XML is an XSLT stylesheet that can be used with any XSLT processor (including Symphony).