I’ve created some markup/css and JavaScript for a custom UI to be used with the HTML5 <video> tag and would like to use XSLT to replace the video elements in my web pages with it.
Here is an example XHTML document that would be transformed:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="layout.css" type="text/css"?>
<?xml-stylesheet href="video_extension.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Example</title>
</head>
<body>
<video src="myvideo.webm"/>
</body>
</html>
video_extension.xsl is the XSLT document I’m trying to create, and it’s output should hopefully be this:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="layout.css" type="text/css"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Example</title>
<script src="video_extension.js" type="text/javascript"/>
<link rel="stylesheet" href="video_extension.css" type="text/css"/>
</head>
<body>
<div class="video-container">
<video src="myvideo.webm"/>
<div class="video-ui>
<!-- additional markup not included -->
</div>
</div>
</body>
</html>
It should leave the rest of the document as is, but add the video extension’s CSS and JavaScript files and then wrap the video elements in a div along with the rest of my UI markup. This needs to work for any valid XHTML5 document and the output should also be valid XHTML5.
Thanks for any help.
You can use the identity rule and override the wanted elements. For example, the following transform:
outputs: