我有一个的.xsl其将XML从DocBook到DITA。我正在运行到一个问题,就是.dita文件多数民众赞成创建破阵外部参照。要解决这个问题,我想尝试强制执行DITA版本在变换(我希望这就是可能的)。所以我的问题是:我怎么有转换后的文档尊重DITA 1.2时,正在转化为

的转变是从DITA开放工具包1.5.2使用docbook2dita插件 这里的电流的.xsl:

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" >
<xsl:import href="./xslt/ditabaseOutput.xsl"/>
<xsl:import href="./xslt/dbReader.xsl"/>

<xsl:output
    method="xml"
    indent="yes"
    omit-xml-declaration="no"
    standalone="no"
    doctype-public="-//OASIS//DTD DITA Composite//EN"
/>
<xsl:template match="/">
    <xsl:apply-templates select="." mode="topic.topic.in"/> 
</xsl:template>

</xsl:stylesheet>
有帮助吗?

解决方案

<强> XSLT 2.0是理想的变换的结果确认到特定的XML模式即可。不支持DTD验证。

所以,如果你找到一个DITA XML模式(而且似乎是一些DITA架构 存在的),则可以很容易地对其进行验证。 下面是一个例子,从Michael Kay的书“XSLT 2.0和XPath 2.0”截取,如何执行结果文档的验证:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="2.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns="http://www.w3.org/1999/xhtml">

<xsl:import-schema namespace="http://www.w3.org/1999/xhtml" 
   schema-location="http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd"/>
<xsl:output method="xhtml" indent="yes"/>                   
<xsl:template match="/">
  <xsl:result-document validation="strict">
    <html>
      <head>
        <title><xsl:value-of select="poem/title"/></title>
      </head>
      <body>
        <h1 align="center"><xsl:value-of select="poem/title"/></h1>
        <p align="center"><i>by </i><xsl:value-of select="poem/author/name"/> 
          (<xsl:value-of select="poem/author/(birth,death)" separator="-"/>)</p>
        <xsl:for-each select="poem/stanza">
          <p>
            <xsl:for-each select="line">
              <xsl:value-of select="."/>
              <xsl:if test="position() != last()"><br/></xsl:if>
            </xsl:for-each>
          </p>
        </xsl:for-each>
      </body>
    </html>
  </xsl:result-document>
</xsl:template>                   
</xsl:stylesheet>

:当施加在下面的XML文档这种转化

<?xml version="1.0"?>
<poem xmlns="http://poetry.org/ns" 
      xsi:schemaLocation="http://poetry.org/ns poem.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <author>
     <name>Rupert Brooke</name>
     <birth>1887-08-03</birth>
     <death>1915-04-23</death>
   </author>
   <date>1912</date>
   <title>The Hill</title>
   <stanza>
      <line>Breathless, we flung us on the windy hill,</line>
      <line>Laughed in the sun, and kissed the lovely grass.</line>
      <line>You said "Through glory and ecstasy we pass;</line>
      <line>Wind, sun, and earth remain, and birds sing still,</line>
      <line>When we are old, are old...." "And when we die</line>
      <line>All's over that is ours; and life burns on</line>
      <line>Through other lovers, other lips" said I,</line>
      <line>"Heart of my heart, our heaven is now, is won!"</line>
   </stanza>
   <stanza>
      <line>We are Earth's best, that learnt her lesson here.</line>
      <line>Life is our cry. We have kept the faith!" we said;</line>
      <line>"We shall go down with unreluctant tread</line>
      <line>Rose-crowned into the darkness!".... Proud we were,</line>
      <line>And laughed, that had such brave true things to say.</line>
      <line>-- And then you suddenly cried, and turned away.</line>
  </stanza>
</poem>

撒克逊EE 9.2.1.2处理器产生以下错误消息:

SystemID: C:\Books\XSLT 2.0 and XPath 2.0\Downloads\Chapter4\ch04\poem-to-xhtml.xsl
Engine name: Saxon-EE 9.2.1.2
Severity: error
Description: Failed to compile stylesheet. 1 error detected.

SystemID: C:\Books\XSLT 2.0 and XPath 2.0\Downloads\Chapter4\ch04\poem-to-xhtml.xsl
Engine name: Saxon-EE 9.2.1.2
Severity: fatal
Description: Attribute align is not permitted in the content model of the complex type of element h1
Start location: 16:0
URL: http://www.w3.org/TR/xslt20/#err-XTTE1510

<强>以下是总结如何实现XML模式验证结果文档的:

0.1。进口的至少一个模式,例如:

<xsl:import-schema namespace="http://www.w3.org/1999/xhtml" 
   schema-location="http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd"/>

0.2。在<xsl:result-document>元件指定严格验证,如下所示:

  <xsl:result-document validation="strict">
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top