div を div で囲んで動作する HTML ページを作成しました。ただし、同じ HTML を使用して XSLT を介して XML を処理すると、ある div が別の div の上に配置されますが、XML/XSLT でこれを行う理由を誰でも考えることができますか?
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
>
<!-- Doctype - about:legacy-compat is XML equivalent of HTML5 doctype -->
<xsl:output method="html" indent="yes"
omit-xml-declaration="yes"
doctype-public="about:legacy-compat"
/>
<xsl:template name="Document" match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>BPD</title>
<link type="text/css" rel="stylesheet" href="big_picture_documentation_v3.css"/>
</head>
<body>
<div id="container">
<div id="floated">
<p>WRAP AROUND ME!</p>
</div>
<xsl:apply-templates/>
</div>
</body>
</html>
</xsl:template>
<xsl:template name="Title" match="title">
<h1>
<xsl:apply-templates/>
</h1>
</xsl:template>
<xsl:template name="subheading" match="subheading">
<h2>
<xsl:apply-templates/>
</h2>
</xsl:template>
</xsl:stylesheet>
これらの div をフォーマットするための CSS を以下に示します。
#container { margin: 5px;padding: 5px;border: 0px solid black;}
#floated { width: 227x;float: left;padding-right: 5px;padding-bottom: 10px;}
XML の例:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="v3.xsl" ?>
<document xmlns:xhtml="http://www.w3.org/1999/xhtml">
<data id="HowToUse" type="example" status="Complete">
<content>
<title>How To Navigate This Guide</title>
<subheading>Using This Documentation</subheading>
</content>
</data>
</document>