我有一个RelaxNG架构,分为几个.rnc
个文件。我希望能够将它们转换为DTD,但trang
抱怨我使用external
指令:
$ trang schema/text.rnc schema/text.dtd
[...]/schema/text.rnc:3:6: error: sorry, "externalRef" is not supported
[...]/schema/text.rnc:4:9: error: sorry, "externalRef" is not supported
[...]/grcxml/schema/text.rnc:6:15: error: sorry, "externalRef" is not supported
[...]/schema/text.rnc:3:6: error: sorry, "externalRef" is not supported
Exception in thread "main" java.lang.NullPointerException
at com.thaiopensource.relaxng.output.dtd.ContentType.ref(ContentType.java:138)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitRef(Analysis.java:232)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitRef(Analysis.java:78)
at com.thaiopensource.relaxng.edit.RefPattern.accept(RefPattern.java:9)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.analyzeContentType(Analysis.java:336)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitGroup(Analysis.java:216)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitGroup(Analysis.java:78)
at com.thaiopensource.relaxng.edit.GroupPattern.accept(GroupPattern.java:5)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.analyzeContentType(Analysis.java:336)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitElement(Analysis.java:118)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitElement(Analysis.java:78)
at com.thaiopensource.relaxng.edit.ElementPattern.accept(ElementPattern.java:9)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.analyzeContentType(Analysis.java:336)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitRef(Analysis.java:232)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitRef(Analysis.java:78)
at com.thaiopensource.relaxng.edit.RefPattern.accept(RefPattern.java:9)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.analyzeContentType(Analysis.java:336)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitDefine(Analysis.java:288)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitDefine(Analysis.java:78)
at com.thaiopensource.relaxng.edit.DefineComponent.accept(DefineComponent.java:39)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitContainer(Analysis.java:278)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitGrammar(Analysis.java:258)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.visitGrammar(Analysis.java:78)
at com.thaiopensource.relaxng.edit.GrammarPattern.accept(GrammarPattern.java:14)
at com.thaiopensource.relaxng.output.dtd.Analysis$Analyzer.analyzeContentType(Analysis.java:336)
at com.thaiopensource.relaxng.output.dtd.Analysis.<init>(Analysis.java:534)
at com.thaiopensource.relaxng.output.dtd.DtdOutputFormat.output(DtdOutputFormat.java:22)
at com.thaiopensource.relaxng.translate.Driver.run(Driver.java:144)
at com.thaiopensource.relaxng.translate.Driver.main(Driver.java:44)
Trang能够将像RelaxNG这样富有表现力的模式填充到一个昏暗的灯泡DTD中,这似乎很奇怪,这个障碍让我感到惊讶。 external
包含非常适合在schemata中共享定义,我不想失去它们。什么是使这成为可能的最好方法?
答案 0 :(得分:2)
如果您不在乎DTD不会将该部门复制到源文件中,您可以先使用jing
:
$ jing -s source.rng > intermediate.rng
$ trang intermediate.rng final.dtd
第一步将所有内容合并为一个文件。第二个将转换。
答案 1 :(得分:1)
我认为你可以使用Trang将.rnc紧凑模式转换为.rng,它应该将外部模式合并到主模式中。一旦你有一个.rng文件,你就可以将它转换为DTD。
另请参阅https://code.google.com/p/jing-trang/issues/detail?id=51和https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=264706。