Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Java中应用XSL样式表时,输出未正确缩进_Java_Xslt_Format_Output_Indentation - Fatal编程技术网

在Java中应用XSL样式表时,输出未正确缩进

在Java中应用XSL样式表时,输出未正确缩进,java,xslt,format,output,indentation,Java,Xslt,Format,Output,Indentation,只是提醒一下,我对Java、XML和XSL还相当陌生,请耐心听我说。:) 我正在做一个uni作业,它要求我使用Java组合两个XML文件 虽然专门使用XSL更直接,但我的任务是使用Java来组合上述文件,并按照日期属性的顺序对XML文档的部分进行排序 所以,;我有正确的工作组合,但我试图格式化我的输出和排序的问题部分 在我的Java代码中,我不得不从最终(组合)输出XML文件中删除某些元素;我一直在使用x.getParentNode().removeChild(x)来实现这一点 这使得我到处都是

只是提醒一下,我对Java、XML和XSL还相当陌生,请耐心听我说。:)

我正在做一个uni作业,它要求我使用Java组合两个XML文件

虽然专门使用XSL更直接,但我的任务是使用Java来组合上述文件,并按照日期属性的顺序对XML文档的部分进行排序

所以,;我有正确的工作组合,但我试图格式化我的输出和排序的问题部分

在我的Java代码中,我不得不从最终(组合)输出XML文件中删除某些元素;我一直在使用x.getParentNode().removeChild(x)来实现这一点

这使得我到处都是空白文本节点,因此我在最后阶段需要重新格式化以下XSL:

<!-- Code removed due to possible plagiarism -->
注:

  • srcDoc1是我组合的XML文档(程序基本上从srcDoc2中提取内容并将其放在srcDoc1中)
在过去的几天里,我一直在我的键盘上敲打我的头,我真的需要一些建议来解释为什么会这样


提前谢谢

我们在评论线程中确定您在Eclipse项目中加载Saxon,但在独立Java应用程序中加载Xalan。

我们在评论线程中确定您在Eclipse项目中加载Saxon,但在独立Java应用程序中加载Xalan。

请说明使用的XSLT处理器?沙兰,撒克逊人,还有其他人?!这有帮助吗:?@uL1,抱歉,忘了提那件事。我在用萨克森。@Michael Kay,谢谢你的链接,我已经找到了,并且得到了相同的输出。如果我把事情搞砸了,我会再试一次,但我很确定我没有。迈克尔凯,当时刚试过,但运气不好。问题是,如果我使用eclipse手动应用XSL,XSL工作得很好;当我试图通过Java代码使用transformer应用它时(如我的OP中的代码所示),它会发出刺耳的声音。请说明使用的XSLT处理器好吗?沙兰,撒克逊人,还有其他人?!这有帮助吗:?@uL1,抱歉,忘了提那件事。我在用萨克森。@Michael Kay,谢谢你的链接,我已经找到了,并且得到了相同的输出。如果我把事情搞砸了,我会再试一次,但我很确定我没有。迈克尔凯,当时刚试过,但运气不好。问题是,如果我使用eclipse手动应用XSL,XSL工作得很好;当我试图通过Java代码使用transformer应用它时,正如我的OP中的代码所示,它会发出刺耳的声音。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE authors
  SYSTEM "output.dtd">
<authors>
   <author>
      <name>AMADEO, Giovanni Antonio</name>
      <born-died>b. ca. 1447, Pavia, d. 1522, Milano</born-died>
      <nationality>Italian</nationality>
      <biography>Giovanni Antonio was....</biography>
      <artworks form="architecture">
         <artwork date="1473">
            <title>Façade of the church</title>
            <technique>Marble</technique>
            <location>Certosa, Pavia</location>
         </artwork>
      </artworks>
   </author>
</authors>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE authors SYSTEM "output.dtd">
<authors>
<author>
<name>AMADEO, Giovanni Antonio</name>
<born-died>b. ca. 1447, Pavia, d. 1522, Milano</born-died>
<nationality>Italian</nationality>
<biography>Giovanni Antonio Amadeo was an Italian early Renaissance sculptor, architect, and engineer. In 1466 he was engaged as a sculptor, with his brother Protasio, at the famous Certosa, near Pavia. He was a follower of the style of Bramantino of Milan, and he represents, like him, the Lombard direction of the Renaissance. He practised cutting deeply into marble, arranging draperies in cartaceous folds, and treating surfaces flatly even when he sculptured figures in high relief. Excepting in these technical points he differed from his associates completely, and so far surpassed them that he may be ranked with the great Tuscan artists of his time, which can be said of hardly any other North-Italian sculptor.</biography>
<artworks form="architecture">
<artwork date="1473">
<title>Façade of the church</title>
<technique>Marble</technique>
<location>Certosa, Pavia</location>
</artwork>
</artworks>
</author>
// Code removed due to possible plagiarism.