minOccurs maxOccurs不适用于dita吗?

时间:2019-04-01 12:10:41

标签: dita

我用xsd中的一个元素修改了minOccurs = 1,并且没有在ditamap中添加该元素。但是dita运作良好。没有警告,没有错误。 该示例是bookmap,它是dita-ot-3.3的形式示例。

xsd:

   <xs:group name="bookmeta.content">
      <xs:sequence>
         <xs:group ref="linktext" minOccurs="1"/>
         <xs:group ref="searchtitle" minOccurs="1"/>
         <xs:group ref="shortdesc" minOccurs="1"/>
         <xs:group ref="author" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="source" minOccurs="1"/>
         <xs:group ref="publisherinformation" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="critdates" minOccurs="1"/>
         <xs:group ref="permissions" minOccurs="1"/>
         <xs:group ref="metadata" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="audience" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="category" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="keywords" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="prodinfo" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="othermeta" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="resourceid" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="ux-window" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="bookid" minOccurs="1"/>
         <xs:group ref="bookchangehistory" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="bookrights" minOccurs="1" maxOccurs="unbounded"/>
         <xs:group ref="data" minOccurs="1" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:group>

ditamap:

  <bookmeta>
    <author>Howe Tuduit</author>
    <bookid>
      <isbn>071271271X</isbn>
      <booknumber>SG99-9999-00</booknumber>
      <maintainer>
        <organization>Retro Tools</organization>
        <person/>
      </maintainer>
    </bookid>
    <bookrights>
      <copyrfirst>
        <year>2004</year>
      </copyrfirst>
      <copyrlast>
        <year>2007</year>
      </copyrlast>
      <bookowner>
        <organization>Retro Tools, Inc.</organization>
      </bookowner>
    </bookrights>
  </bookmeta>

我认为minOccurs应该起作用。输出将失败。

1 个答案:

答案 0 :(得分:0)

您必须修改了另一个与DITA-OT参考不同的XSD文件。

如果我修改dita-ot-3.3\plugins\org.oasis-open.dita.v1_3\schema\bookmap\xsd\bookmapMod.xsd进行测试,则DITA-OT构建将失败,并出现以下错误。这是预期的结果。

[bookmapMod.xsd]

  <xs:group name="bookmeta.content">
     <xs:sequence>
        <xs:group ref="linktext" minOccurs="1"/>
        <xs:group ref="searchtitle" minOccurs="1"/>
        <xs:group ref="shortdesc" minOccurs="1"/>
        <xs:group ref="author" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="source" minOccurs="1"/>
        <xs:group ref="publisherinformation" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="critdates" minOccurs="1"/>
        <xs:group ref="permissions" minOccurs="1"/>
        <xs:group ref="metadata" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="audience" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="category" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="keywords" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="prodinfo" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="othermeta" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="resourceid" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="ux-window" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="bookid" minOccurs="1"/>
        <xs:group ref="bookchangehistory" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="bookrights" minOccurs="1" maxOccurs="unbounded"/>
        <xs:group ref="data" minOccurs="1" maxOccurs="unbounded"/>
     </xs:sequence>
  </xs:group>

[Bookmap]

<?xml version="1.0" encoding="UTF-8"?>
<bookmap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:bookmap.xsd">
    <booktitle>
        <mainbooktitle>BookMapTest</mainbooktitle>
    </booktitle>
    <bookmeta>
        <author>Howe Tuduit</author>
        <bookid>
            <isbn>071271271X</isbn>
            <booknumber>SG99-9999-00</booknumber>
            <maintainer>
                <organization>Retro Tools</organization>
                <person/>
            </maintainer>
        </bookid>
        <bookrights>
            <copyrfirst>
                <year>2004</year>
            </copyrfirst>
            <copyrlast>
                <year>2007</year>
            </copyrlast>
            <bookowner>
                <organization>Retro Tools, Inc.</organization>
            </bookowner>
        </bookrights>
    </bookmeta>
    <chapter navtitle="Chapter"/>
</bookmap>

[错误日志]

  

建立失败   D:\ DITA-OT \ dita-ot-3.3 \ plugins \ org.dita.base \ build.xml:31:   执行此行时发生以下错误:   D:\ DITA-OT \ dita-ot-3.3 \ plugins \ org.dita.base \ build_preprocess.xml:62:   无法运行管道:[DOTJ012F] [FATAL]无法解析输入   文件   '文件:/ C:/Users/toshi/OneDrive/Documents/test/dita/20190402-xsd/Bookmaptest.ditamap'.:   文件:/ C:/Users/toshi/OneDrive/Documents/test/dita/20190402-xsd/Bookmaptest.ditamap   第-1行:发现从元素“作者”开始的无效内容。一   预期为“ {linktext}”。

     

总时间:2秒

请注意,不建议直接修改OASIS XSD文件。这仅用于测试。

[HTML帮助输出的答案]

  

我修改   dita-ot-3.3 \ plugins \ org.oasis-open.dita.v1_3 \ schema \ bookmap \ xsd \ bookmapMod.xsd,然后像这样编译:dita -f htmlhelp -i   D:\ dita-ot-3.3 \ docsrc \ samples \ taskbook.ditamap -o F:\ Study \ Dita \ output   -v。当然,我使用bookmap.xsd而不是DTD修改了任务手册引用。输出仍然很好。没错–

这是因为HTML帮助输出采用了下面介绍的“ preprocess2”:

Map-first preprocessing

如果在dita-ot-3.3 \ plugins \ org.dita.htmlhelp \ build_dita2htmlhelp.xml中将以下行从“ preprocess2”修改为“ preprocess”,您肯定会收到验证错误。

<target name="dita2htmlhelp" unless="noMap" depends="dita2htmlhelp.init,
build-init, use-init.envhhcdir, use-init.hhcdir, preprocess2,
htmlhelp.topics, htmlhelp.copy-image, copy-css">
<antcall target="dita.map.htmlhelp"/>
</target>
  

preprocess.init:

 [echo] *****************************************************************

 [echo] * input = D:\DITA-OT\dita-ot-3.3\docsrc\samples\taskbook.ditamap

 [echo] *****************************************************************
     

ditaval合并:

     

gen-list:[gen-list]将Xerces语法池用于DTD和模式   缓存。 [gen-list]处理   文件:/ D:/DITA-OT/dita-ot-3.3/docsrc/samples/taskbook.ditamap错误:   无法运行管道:[DOTJ012F] [FATAL]无法解析输入   文件'文件:/ D:/DITA-OT/dita-ot-3.3/docsrc/samples/taskbook.ditamap'.:   文件:/ D:/DITA-OT/dita-ot-3.3/docsrc/samples/taskbook.ditamap行   14:cvc-complex-type.2.4.a:发现无效的内容始于   元素“作者”。预期为“ {linktext}”之一。