Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception Writing Output From API #691

Open
mandrachek opened this issue Sep 2, 2020 · 3 comments
Open

Exception Writing Output From API #691

mandrachek opened this issue Sep 2, 2020 · 3 comments

Comments

@mandrachek
Copy link

I'm utilizing the CFLintAPI, and am attempting to call result.writeHTML("default.xsl",writer) - it doesn't matter which htmlStyle value I provide, I get:

net.sf.saxon.trans.XPathException: Values of 'standalone' and 'omit-xml-declaration' conflict

@ryaneberly
Copy link
Contributor

ryaneberly commented Sep 2, 2020

Looks like that method is used two places
https://github.com/cflint/CFLint/search?q=writeHTML&unscoped_q=writeHTML
you tried "plain.xsl" as well?

@mandrachek
Copy link
Author

Yeah, I tried all of the ones in https://github.com/cflint/CFLint/tree/master/src/main/resources/findbugs
I know had a similar issue previously when working with spotbugs (which is the replacement for findbugs) - I think it might be down to changes in the XML parsing between Java 7 and Java 8.

spotbugs/spotbugs#1000
spotbugs/spotbugs-gradle-plugin#114

@mandrachek
Copy link
Author

I get this error if I use plain.xsl or default.xsl and writeHTML or writeFindBugsXml

Error evaluating ((attr{sequence=...}, ...)) on line 13 column 42 
  SEPM0009: Values of 'standalone' and 'omit-xml-declaration' conflict
  In template rule with match="/" on line 9 of 

This is the stack trace from writeHTML():

Caused by: java.io.IOException: net.sf.saxon.trans.XPathException: Values of 'standalone' and 'omit-xml-declaration' conflict
        at com.cflint.api.CFLintResult.writeHTML(CFLintResult.java:69)
        at com.cflint.api.CFLintResult$writeHTML$0.call(Unknown Source)
        at build_btckcrxfi6v2dy709jqu7edvu$_run_closure11$_closure23.doCall(/Users/andrachekm/IdeaProjects/proj/build.gradle:191)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.doExecute(AbstractTask.java:680)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.lambda$execute$0(AbstractTask.java:667)
        at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication.reapply(DefaultUserCodeApplicationContext.java:86)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:667)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:642)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:555)
        ... 90 more
Caused by: net.sf.saxon.trans.XPathException: Values of 'standalone' and 'omit-xml-declaration' conflict
        at net.sf.saxon.serialize.XMLEmitter.writeDeclaration(XMLEmitter.java:271)
        at net.sf.saxon.serialize.XMLEmitter.openDocument(XMLEmitter.java:188)
        at net.sf.saxon.serialize.XMLEmitter.startElement(XMLEmitter.java:359)
        at net.sf.saxon.serialize.XMLIndenter.startElement(XMLIndenter.java:119)
        at net.sf.saxon.event.ProxyReceiver.startElement(ProxyReceiver.java:132)
        at net.sf.saxon.event.SequenceNormalizer.startElement(SequenceNormalizer.java:88)
        at net.sf.saxon.event.NamespaceReducer.startElement(NamespaceReducer.java:75)
        at net.sf.saxon.event.ComplexContentOutputter.startContent(ComplexContentOutputter.java:640)
        at net.sf.saxon.event.ComplexContentOutputter.startElement(ComplexContentOutputter.java:271)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:345)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:299)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:735)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:132)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:352)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:299)
        at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:721)
        at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:352)
        at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:532)
        at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:747)
        at net.sf.saxon.s9api.AbstractXsltTransformer.applyTemplatesToSource(AbstractXsltTransformer.java:347)
        at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:349)
        at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:71)
        at com.cflint.XMLOutput.outputFindBugs(XMLOutput.java:157)
        at com.cflint.HTMLOutput.output(HTMLOutput.java:49)
        at com.cflint.api.CFLintResult.writeHTML(CFLintResult.java:67)
        ... 101 more

FWIW, I'm running this from a gradle task using Gradle 6.7:

buildscript {
    repositories {
         jcenter()
         mavenCentral()
    }
    dependencies {
                classpath 'com.github.cflint:CFLint:1.5.0'
    }
}

import com.cflint.api.CFLintAPI
import com.cflint.api.CFLintResult
import com.cflint.Levels

task cflint(group: 'verification') {

    doFirst {
        mkdir "${project.buildDir}/reports/cflint"
    }

    doLast {
        CFLintAPI api = new CFLintAPI()

        def scanFiles = new ArrayList<String>()

        fileTree("src").each {
            if (it.name.toLowerCase().endsWithAny("cfc","cfm")) {
                scanFiles.add(it.absolutePath)
            }
        }
        CFLintResult result = api.scan(scanFiles)

        result.writeXml(
                file("${project.buildDir}/reports/cflint/main.xml").newWriter()
        )

        /*
            --- these both fail ---
        result.writeHTML(
            "plain.xsl",
            file("${project.buildDir}/reports/cflint/main.html").newWriter()
        )

        result.writeFindBugsXml(file("${project.buildDir}/reports/cflint/main.xml").newWriter())
         */
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants