简体   繁体   English

Groovy Codenarc.xml org.xml.sax.SAXParseException xsi:schemaLocation与元素类型规则集未绑定

[英]Groovy Codenarc.xml org.xml.sax.SAXParseException xsi:schemaLocation not associated with element type ruleset not bound

I'm using Gradle 2.3 and project has Groovy code. 我正在使用Gradle 2.3,并且项目具有Groovy代码。 For static code analysis, I'm using Codenarc (ie project folder has "config/codenarc/codenarc.xml" file). 对于静态代码分析,我使用Codenarc(即项目文件夹中包含“ config / codenarc / codenarc.xml”文件)。

In the build.gradle / GRADLE_HOME/init.d/top-level.gradle file, I have: 在build.gradle / GRADLE_HOME / init.d / top-level.gradle文件中,我有:

apply plugin: 'codenarc'

   codenarc {
     ignoreFailures = true
     configFile = file("config/codenarc/codenarc.xml")
   }

But while compiling this project, I'm getting the following error. 但是在编译该项目时,出现以下错误。

13:49:00 :codenarcAcceptanceTest UP-TO-DATE
13:49:01 :codenarcIntegrationTest FAILED
13:49:01 
13:49:01 FAILURE: Build failed with an exception.
13:49:01 
13:49:01 * What went wrong:
13:49:01 Execution failed for task ':codenarcIntegrationTest'.
13:49:01 > org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 173; The prefix "xsi" for attribute "xsi:schemaLocation" associated with an element type "ruleset" is not bound.
13:49:01 
13:49:01 * Try:
13:49:01 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
13:49:01 
13:49:01 BUILD FAILED

File contents in codenarc.xml file are: codenarc.xml文件中的文件内容为:

<ruleset xsi:schemaLocation="http://codenarc.org/ruleset/1.0 http://codenarc.org/ruleset-schema.xsd" xsi:noNamespaceSchemaLocation="http://codenarc.org/ruleset-schema.xsd">
   <description>Sample rule set</description>
   <ruleset-ref path="rulesets/basic.xml"/>
   <ruleset-ref path="rulesets/braces.xml">
      <rule-config name="IfStatementBraces">
         <property name="priority" value="3"/>
      </rule-config>
   </ruleset-ref>
   <ruleset-ref path="rulesets/concurrency.xml"/>
  <ruleset-ref path="rulesets/convention.xml"/>
   <ruleset-ref path="rulesets/design.xml"/>
   <ruleset-ref path="rulesets/dry.xml">
      <rule-config name="DuplicateStringLiteral">
         <property name="doNotApplyToClassNames" value="*Spec"/>
      </rule-config>
      <rule-config name="DuplicateNumberLiteral">
         <property name="doNotApplyToClassNames" value="*Spec"/>
      </rule-config>
      <rule-config name="DuplicateMapLiteral">
         <property name="doNotApplyToClassNames" value="*Spec"/>
      </rule-config>
      <rule-config name="DuplicateListLiteral">
         <property name="doNotApplyToClassNames" value="*Spec"/>
      </rule-config>
   </ruleset-ref>
   <ruleset-ref path="rulesets/exceptions.xml"/>
   <ruleset-ref path="rulesets/formatting.xml"/>
   <ruleset-ref path="rulesets/generic.xml"/>
   <ruleset-ref path="rulesets/grails.xml"/>
   <ruleset-ref path="rulesets/groovyism.xml"/>
   <ruleset-ref path="rulesets/imports.xml">
      <exclude name="MisorderedStaticImports"/>
   </ruleset-ref>
   <ruleset-ref path="rulesets/jdbc.xml"/>
   <ruleset-ref path="rulesets/junit.xml"/>
   <ruleset-ref path="rulesets/logging.xml"/>
   <ruleset-ref path="rulesets/naming.xml">
      <rule-config name="FieldName">
         <property name="ignoreFieldNames" value="log"/>
      </rule-config>
      <rule-config name="MethodName">
         <property name="doNotApplyToClassNames" value="*Spec"/>
      </rule-config>
      <exclude name="FactoryMethodName"/>
   </ruleset-ref>
   <ruleset-ref path="rulesets/security.xml">
      <exclude name="JavaIoPackageAccess"/>
   </ruleset-ref>
   <ruleset-ref path="rulesets/serialization.xml"/>
   <ruleset-ref path="rulesets/size.xml"/>
   <ruleset-ref path="rulesets/unnecessary.xml">
      <exclude name="UnnecessaryPackageReference"/>
   </ruleset-ref>
   <ruleset-ref path="rulesets/unused.xml"/>
</ruleset>

The xml did not know what xsi is you have add this as prefix from the correct namespace url. xml不知道您使用了什么xsi作为来自正确名称空间url的前缀。 Try the following header: 尝试以下标头:

<ruleset xmlns="http://codenarc.org/ruleset/1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://codenarc.org/ruleset/1.0 http://codenarc.org/ruleset-schema.xsd"
    xsi:noNamespaceSchemaLocation="http://codenarc.org/ruleset-schema.xsd">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.xml.sax.SAXParseException:引用了实体“ndash”,但未声明 - org.xml.sax.SAXParseException: The entity “ndash” was referenced, but not declared org.xml.sax.SAXParseException:文档无效:未找到语法。 - org.xml.sax.SAXParseException: Document is invalid: no grammar found. 在Java中调用Webservice时出现“ org.xml.sax.SAXException:SimpleDeserializer遇到子元素,这是不希望的……”错误 - “org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected…” error while calling webservice in java XML编译SAX异常 - XML compiling SAX exception 解析XML文件时如何国际化SAXParseException? - How to internationalization SAXParseException while parsing XML file? 如何在Try / Catch中将Java SAXParseException抛出给错误的XML文档 - How to throw Java SAXParseException for bad XML documents in Try/Catch SAXParseException:元素类型SOAP:Text后面必须是属性说明“&gt;”或“ /&gt;” - SAXParseException: Element type SOAP:Text must be followed by either attribute specifications, “>” or “/>” 空元素上的Xml反序列化失败 - Xml Deserialization Fails on Empty Element 如何使用linq to xml检查xml文件是否包含特定元素 - How to check if a xml file contains specific element using linq to xml 引起原因:java.lang.ClassNotFoundException:org.apache.commons.io.FileUtils,maven pom.xml wa - Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils, maven pom.xml wa
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM