Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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
Xml 使用CSPLIT的具有多个Doctype声明的文件_Xml_Command Line_Csplit - Fatal编程技术网

Xml 使用CSPLIT的具有多个Doctype声明的文件

Xml 使用CSPLIT的具有多个Doctype声明的文件,xml,command-line,csplit,Xml,Command Line,Csplit,我有一个包含多个Doctype声明的文件。我试图使用CSPLIT将文件分解成更小的块,但遇到了一些问题。 以下是我正在使用的文件的示例: <?xml version="1.0" ?> <!DOCTYPE pmc-articleset PUBLIC "-//NLM//DTD ARTICLE SET 2.0//EN" "https://dtd.nlm.nih.gov/ncbi/pmc/articleset/nlm-articlese

我有一个包含多个Doctype声明的文件。我试图使用CSPLIT将文件分解成更小的块,但遇到了一些问题。 以下是我正在使用的文件的示例:

<?xml version="1.0" ?>
<!DOCTYPE pmc-articleset PUBLIC "-//NLM//DTD ARTICLE SET 2.0//EN" "https://dtd.nlm.nih.gov/ncbi/pmc/articleset/nlm-articleset-2.0.dtd">

<pmc-articleset><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="research-article">
  <?properties open_access?>
  <front>
    <p>
    Apple
    </p>
  </front>
</article>
</pmc-articleset>
<?xml version="1.0" ?>
<!DOCTYPE pmc-articleset PUBLIC "-//NLM//DTD ARTICLE SET 2.0//EN" "https://dtd.nlm.nih.gov/ncbi/pmc/articleset/nlm-articleset-2.0.dtd">
<pmc-articleset><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="research-article">
  <?properties open_access?>
  <front>
    <p>
    Banana
    </p>
  </front>
</article>
</pmc-articleset>

任何解决方案都将不胜感激。谢谢大家!

我不知道c劈,但是,你知道,没有一个正则表达式能在一个文件的中间检测一个XML声明,它具有100%的可靠性。在注释或CDATA节中很容易隐藏一些看起来像XML声明的内容,而且无意中这样做的可能性也不大。因此,这是一个非常糟糕的文件格式选择。不幸的是,这是我必须使用的唯一文件格式。我需要找到一种方法来解析它,我认为分解它是最好的方法。
csplit -z --prefix output_file --suffix-format '%02d.xml' handSurgery.xml '/^<[?]xml[ ]/' '{*}'
csplit: illegal option -- z