2010-11-19 17 views
1

xmlをdocbookからDITAに変換する.xslがあります。私が実行している問題は、作成された.ditaファイルが作成した外部参照を破壊することです。それを修正するために、変換中にditaバージョンを強制しようとします(可能なことを望みます)。ですから、私の質問は、変換された文書をDITA 1.2が変換されているときにどのように尊重するかです。 2.0特定のXMLスキーマに変換した結果を検証するために理想的であるDITA Open Toolkit 1.5.2 XSLTスタイルシートのDITAバージョンを適用する

<?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> 
+0

良い質問、+1 XSLT 2.0変換の結果のスキーマ検証を実行する方法の例については、私の答えを参照してください。 –

+1

結果ドキュメントの検証に関するDimitreの答え以外にも、これは明確化が必要だと思います。変換は入力から出力への関数です。 1つのタイプの結果(DITA 1.1など)を出力するには、その関数の定義方法に依存します。関数自体が(パラメータで)指定する方法を提供しない場合、関数定義(拡張子、構成など)を変更する必要があります –

+0

@Alejandro:はい、私がやっていることを正確に打つ。私はDITA OTプラグインdocbook2ditaを使用しようとしています。それは数年前に書かれたものです。 DITA 1.2より前。 TODOの部分では「DITA 1.1とDocBook 5へのアップグレード」と書かれています。 dita 1.2にアップグレードするにはどうすればよいですか? – Ace

答えて

1

XSLT:

変換は、ここで現在の.xslだdocbook2ditaプラグイン を使用DITAオープンツールキット1.5.2からのものです。 DTD検証はサポートされていません。

DITA用のXMLスキーマが見つかった場合(そして、some DITA schemaが存在すると思われます)、簡単に検証できます。ここで は、どのようにその結果、文書の検証を行うために、マイケル・ケイ氏の著書「XSLT 2.0とXPath 2.0」から取った例です:

この変換は、次のXML文書に適用され
<?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 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スキーマ検証を達成する方法を要約します。

.1。少なくとも1つのスキーマをインポートします。例えば、

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

.2です。 <xsl:result-document>要素では、次のように厳密な検証を指定します。

<xsl:result-document validation="strict"> 
+0

+1情報。 – LarsH

+0

@Dimititre xslt検証の重要性に同意しますが、スキーマが私の問題を解決する方法であるとは確信していません。探している.XSLTが含まれていないと思われます。質問へのコメントは、私が意味することを明確にするのに役立ちます。 – Ace

+0

@Ace:もちろん、スキーマをインポートする必要があります。 "見ている人の.XSLTは、スキーマのインポートが含まれていないようです"というのは当然です。* xsltコードに ' 'ディレクティブを挿入する必要があります。 –

関連する問題