
このコマンドラインツールは、適切なフォーマットのためにXMLファイルを検証します。それらが正しくフォーマットされていない場合、違いを印刷し、エラーで終了します。 2つの方法を使用できます。1)XML-ISHファイル(XML、XSD、XSL、またはXHTMLなど)が正しくフォーマットされていない場合、2) --fixオプションを使用して正しくフォーマットします。
このブログ投稿を最初に読んでください: XCOP—XMLスタイルチェッカー。
Rubyがインストールされていることを確認してから、ツールをインストールしてください。
$ gem install xcopローカルに実行して、その出力を読み取ります。
$ xcop --helpXMLファイルのフォーマットを検証するには、名前を引数として渡すだけです。
$ xcop file1.xml file2.xmlファイルが正しくフォーマットされておらず、 xcop文句を言う場合は、 --fixオプションを使用して、それらを「美化」するように依頼できます。
$ xcop --fix broken-file.xmlディレクトリ内のすべてのファイルを修正するには、実行できる(ファイル名がスペースが含まれている場合は機能しません):
$ xcop --fix $( find . -name ' *.xml ' ) コマンドラインオプションを、 xcopを開始するディレクトリの.xcopファイルに配置できます。各オプションは、ファイル内の単一行を取得する必要があります。それらはすべて、指定したオプションのリストに追加されます。たとえば、このブログ投稿で提案されているように:
--license=LICENSE.txt
--nocolor
--quiet
--include=**/*
--exclude=**/*.xsl
--exclude=**/*.html
~/.xcopファイル(個人のホームディレクトリ内)を作成することもできます。これは、コマンドラインオプションにも読み取られて追加されます。
Rakefileでの使用方法は?これがあなたがそこに必要とするものです:
require 'xcop/rake_task'
desc 'Run XCop on all XML/XSL files in all directories'
Xcop :: RakeTask . new ( :xcop ) do | task |
task . license = 'LICENSE.txt' # no license by default
task . quiet = true # FALSE by default
task . includes = [ '**/*.xml' , '**/*.xsl' ] # xml|xsd|xhtml|xsl|html by default
task . excludes = [ 'target/**/*' ] # empty by default
end .github/workflows/xcop.ymlでリポジトリに新しいワークフローファイルを作成します:
---
name : XCOP
" on " :
# run on push to master events
push :
branches :
- master
# run on pull requests to master
pull_request :
branches :
- master
jobs :
build :
runs-on : ubuntu-latest
steps :
- uses : actions/checkout@v2
- uses : g4s8/xcop-action@masterライセンスの場所またはファイルパターンをカスタマイズするには、アクション入力licenseとfiles使用します。
- uses : g4s8/xcop-action@master
with :
license : MY_LICENSE.txt
files : " src/*.xml " pom.xmlで使用する方法は?Maven-Antrun-Pluginの助けを借りて統合できます。
< project >
[...]
< build >
[...]
< plugins >
[...]
< plugin >
< artifactId >maven-antrun-plugin</ artifactId >
< version >1.8</ version >
< executions >
< execution >
< phase >verify</ phase >
< configuration >
< target >
< apply executable = " xcop " failonerror = " true " >
< arg value = " --license " />
< arg value = " LICENSE.txt " />
< fileset dir = " . " >
< include name = " **/*.xml " />
< include name = " **/*.xsd " />
< exclude name = " target/**/* " />
< exclude name = " .idea/**/* " />
</ fileset >
</ apply >
</ target >
</ configuration >
< goals >
< goal >run</ goal >
</ goals >
</ execution >
</ executions >
</ plugin >
</ plugins >
</ build >
</ project >project.xmlで使用する方法は?このようなものは機能するはずです:
< project >
[...]
< target name = " xcop " >
< apply executable = " xcop " failonerror = " true " >
< arg value = " --license " />
< arg value = " LICENSE.txt " />
< fileset dir = " . " >
< include name = " **/*.xml " />
< include name = " **/*.xsd " />
< exclude name = " target/**/* " />
< exclude name = " .idea/**/* " />
</ fileset >
</ apply >
</ target >
</ project >これらのガイドラインを読んでください。プルリクエストを提供する前に、ビルドが緑色であることを確認してください。 Ruby 2.3+とバンドラーをインストールする必要があります。それから:
$ bundle update
$ bundle exec rake
クリーンで、エラーメッセージが表示されない場合は、プルリクエストを送信してください。