将CSS添加到XML并上传到Saxonica

时间:2017-09-09 23:38:19

标签: html css xml

尝试将CS​​S添加到XML并上传到Saxonica以获取HTML输出。每当我尝试时,我都会收到Saxonica的错误:SEPM0004:什么时候独立'或者' doctype-system'指定,文件必须   合式;但是这个文档包含一个顶级文本节点 什么时候独立'或者' doctype-system'如果规定,文件必须格式正确;但是这个文档包含一个顶级文本节点 XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="measurements4.css"?>
<measurements>
 <measurement typeOfMeasurement="disType">  
    <distance measureDistance="imperial">1.45</distance>
 </measurement>
 <measurement typeOfMeasurement="weiType">
    <weight measureWeight="troy">.6</weight>
 </measurement>
 <measurement typeOfMeasurement="disType">
    <distance measureDistance="metric">25</distance>
 </measurement>
</measurements>

XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" doctype-public="htmlPUBLIC//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" method="xml"/>

<xsl:template match="/html">
  <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
    <title>Measurements through XML to HMTL</title>
    <link rel="stylesheet" type="text/css" href="measurements4.css" />
   </head>
   <body>
    <p>The three measurements that I want transformed.</p>
    <p>There are 2 distance measurements</p>
    <p>There is 1 weight measurement</p>
   </body>
  </html> 
    <p>A weight measurement using the <span><xsl:value-of select="/weight/@measureWeight"/></span> scale is:</p><br />
    <h3>The amount of weight is <span><xsl:value-of select="//weight"/></span></h3><br />
   <xsl:for-each select="/measurements/measurement">
   <xsl:if test="distance">
    <p>A distance measurement using the <span><xsl:value-of select="distance/@measureDistance"/></span> scale is:</p><br />
    <h3>The length of distance is <span><xsl:value-of select="distance"/></span></h3><br />
    <p><xsl:apply-templates select="measurements/measurement"/></p>
   </xsl:if>
   </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

的CSS:

distance{
   display:block; border-style:solid; border-width:3px; float:left; width:45%;}
weight{
   display:block; border-style:solid; border-width:3px; float:right; width:45%;}
imperial{
   display:inline; border-style:solid; border-width:3px; float:left; width:30%;}
metric{
   display:inline; border-style:solid; border-width:3px; float:left; width:30%;}
gram{
   display:inline; border-style:solid; border-width:3px; float:right; width:30%;}
troy{
   display:inline; border-style:solid; border-width:3px; float:right; width:30%;}

非常感谢任何帮助。

0 个答案:

没有答案