Fail to transform DITA into new type

63 views
Skip to first unread message

pkuc...@gmail.com

unread,
Dec 11, 2018, 5:26:15 AM12/11/18
to DITA-OT Users
Hello,

I have a customized plugin to transform DITA into a new format, aiml. I have implemented the plugin into DITA-OT, but I didn't get the expected results. There is nothing else in the output file except the declaration. 
<?xml version="1.0" encoding="UTF-8"?>
Here is my XSLT file:
 <xsl:stylesheet version="2.0" 
   
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   
<xsl:template match="*[contains(@class, ' topic/topic topic/concept ')]">
   
<xsl:for-each select="*[contains(@class, ' topic/foreign category-d/category
    ')]"
>
   
<xsl:copy-of select="."/>
   
</xsl:for-each>
   
</xsl:template>
   
</xsl:stylesheet>
My test XML file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE concept SYSTEM "aimlDomain.dtd">
<?xml-stylesheet type="text/xsl" href="aimlTest.xsl"?>
<concept>
<category>
   
<pattern>_ TOPIC ELEMENT ATTRIBUTE</pattern>
   
<template><srai>REQUIRED TOPIC AND MAP ELEMENT ATTRIBUTES</srai>
   
</template>
</category>
<category>
   
<pattern>TOPIC ELEMENT ATTRIBUTE _</pattern>
   
<template><srai>REQUIRED TOPIC AND MAP ELEMENT ATTRIBUTES</srai>
   
</template>
</category>
</concept>
The element <category> is the new domain I add through element specialization, which is specialized from <foreign> element.
When I run the single DITA file, I got an error message that the input cannot be loaded. I guess maybe there is something wrong with the DTD file integration, but I don't know how to fix it.
I have put my test code on Github: https://github.com/ant28/aimlTest



Robert D Anderson

unread,
Dec 11, 2018, 10:23:55 AM12/11/18
to pkuc...@gmail.com, DITA-OT Users

Your starting match statement uses an incorrect class attribute, so it would not match anything:


<xsl:template match="*[contains(@class, ' topic/topic topic/concept ')]">

The final class attribute token for the <concept> element is concept/concept, not topic/concept.

Generally speaking you shouldn't include both tokens in there, because while the tokens must remain the same, the value would be valid with more whitespace in between topic and concept. Try just using the correct concept token:
<xsl:template match="*[contains(@class, ' concept/concept ')]">

Robert D. Anderson
DITA-OT lead and Co-editor DITA 1.3 specification
Marketing Services Center

E-mail: roba...@us.ibm.com

11501 BURNET RD,, TX, 78758-3400, AUSTIN, USA
IBM


Inactive hide details for pkuchenli---12/11/2018 04:26:22 AM---Hello, I have a customized plugin to transform DITA into a new fpkuchenli---12/11/2018 04:26:22 AM---Hello, I have a customized plugin to transform DITA into a new format, aiml. I

--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pkuc...@gmail.com

unread,
Dec 12, 2018, 3:22:22 AM12/12/18
to DITA-OT Users
Thanks for your help! I have changed the starting match statement
<xsl:template match="*[contains(@class, ' concept/concept ')]">
but I still didn't get the expected output file. When I see the log, I find an error message says that "[move-meta] I/O error reported by XML parser processing file:/C:/Users/lenovo/Desktop/dita-ot-3.0/temp/temp20181212155414075/test.dita: C:\Users\lenovo\Desktop\dita-ot-3.0\temp\temp20181212155414075\test.dita (系统找不到指定的文件。)"  The XML parser doesn't find the file. I don't know whether this problem has something to do with the DTD file.
Because of the limited space, you can refer to the concept.dtd file in Github, here is the link:https://github.com/ant28/aimlTest/blob/master/resource/concept.dtd


在 2018年12月11日星期二 UTC+8下午6:26:15,pkuc...@gmail.com写道:

Eliot Kimber

unread,
Dec 12, 2018, 10:01:31 AM12/12/18
to DITA-OT Users
The file not found message often indicates that the document's DTD can't be found--this is a behavior that is fixed in the latest OT version I think. 

But in any case your concept is not a valid topic as there is no title element and it cannot be valid to have a specialization of <foreign> as a direct child of <concept> (or any form of topic because the base content model for topic does not allow it.

The fact that your XML document does not meet the basic requirements for the structure of topics may or may not affect processing, for example a processor that expects every topic to have a title element as its first child.

Cheers,

Eliot


--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Eliot Kimber

Mark Giffin

unread,
Dec 12, 2018, 12:25:21 PM12/12/18
to DITA-OT Users
Hi Maggie, I wrote an answer on this to your stackoverflow question:


I tried to simplify what you are doing. Does this not work?

Regards,
Mark

pkuc...@gmail.com

unread,
Dec 13, 2018, 10:24:15 PM12/13/18
to DITA-OT Users
Thanks so much. I have seen your answer on the StackOverflow, but it didn't work out. I want to know what tool you use to parse the file. I tried it in the DITA-OT and Oxygen, both of them fails.

Regards,
Maggie

在 2018年12月13日星期四 UTC+8上午1:25:21,Mark Giffin写道:

pkuc...@gmail.com

unread,
Dec 13, 2018, 10:34:28 PM12/13/18
to DITA-OT Users
Thank you, Eliot. I am trying to figure out the possible reason for the problems. Do you mean that <foreign> element must be embedded in the <title> element ? Is it correct to make it as a direct child of <p>?

Regards,
Maggie

在 2018年12月12日星期三 UTC+8下午11:01:31,Eliot Kimber写道:

pkuc...@gmail.com

unread,
Dec 14, 2018, 6:19:53 AM12/14/18
to DITA-OT Users
Hello, Mark

I rewrote an XML file as the following:
java -jar Saxon-HE-9.8.0-5.jar -s:test1.dita -xsl:aimlTest.xsl -o:output-file.xml

<?xml version="1.0" encoding="utf-8"?>
<concept id="test">
  <title>This file is for test</title>
  <conbody>
    <p>
      <category-ai>
           <pattern>WHAT IS DITA</pattern>
           <template>DITA is kind of content organization stucture.</template> 
       </category-ai>
  <category-ai>
           <pattern>WHAT IS DITA</pattern>
           <template>DITA is kind of content organization stucture.</template> 
       </category-ai>
   <category-ai>
           <pattern>WHAT IS DITA</pattern>
           <template>DITA is kind of content organization stucture.</template> 
       </category-ai>
    </p>
  </conbody>
</concept>

Here is the XSLT file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="p">
     <xsl:for-each select="category-ai">
     <xsl:copy-of select="."/>
</xsl:for-each>
   </xsl:template>
</xsl:stylesheet>

The output file is as the following:
<?xml version="1.0" encoding="UTF-8"?>
  This file is for test
  
    <category-ai>
           <pattern>WHAT IS DITA</pattern>
           <template>DITA is kind of content organization stucture.</template> 
       </category-ai><category-ai>
           <pattern>WHAT IS DITA</pattern>
           <template>DITA is kind of content organization stucture.</template> 
       </category-ai><category-ai>
           <pattern>WHAT IS DITA</pattern>
           <template>DITA is kind of content organization stucture.</template> 
       </category-ai>

I didn't select the <title> in XSLT file, but its content still appears. How can I fix this problem? 

Regards,
Maggie

在 2018年12月14日星期五 UTC+8上午11:24:15,pkuc...@gmail.com写道:

Mark Giffin

unread,
Dec 14, 2018, 12:57:41 PM12/14/18
to DITA-OT Users
Maggie, you can add this template to your existing XSLT and it will remove the <title> content:

<xsl:template match="title"/>

So it would be like this:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="p">
     <xsl:for-each select="category-ai">
       <xsl:copy-of select="."/>
     </xsl:for-each>
   </xsl:template>
   <xsl:template match="title"/>
</xsl:stylesheet>

pkuc...@gmail.com

unread,
Dec 14, 2018, 10:16:31 PM12/14/18
to DITA-OT Users
Thank you, Mark. It works! Could you tell me why it works after adding <xsl:template match="title"/>?
Thanks!

Regards,
Maggie
在 2018年12月15日星期六 UTC+8上午1:57:41,Mark Giffin写道:

Lief Erickson

unread,
Dec 15, 2018, 12:49:35 AM12/15/18
to pkuc...@gmail.com, DITA-OT Users
It works because you're not specifically matching on the "title" element name. However, because the template is empty--there are no instructions for what to do with "title"--all of the text that is in "title" is not output. 

I know this was just a test, but just to be clear so you don't get too far down the path and have to redo your templates, you always want to create templates that match on the @class attribute rather than an element name. This is the proper way with DITA processing.

For example, you would want this:
<xsl:template match="*[contains(@class, ' topic/title ')]"/>

instead of
<xsl:template match="title"/>

Finally, I did some work on an AIML project a few months ago. I'd be very interested in this plugin if you're able to make it available in the DITA-OT plugin library.

-Lief




Reply all
Reply to author
Forward
0 new messages