nikku / node-xsd-schema-validator

A schema (XSD) validator for NodeJS
https://www.npmjs.com/package/xsd-schema-validator
MIT License
51 stars 24 forks source link

invalid xml (status=WITH_ERRORS) when run the validator on Node docker image with JAVA #31

Closed fadiakkad closed 8 months ago

fadiakkad commented 1 year ago

Hi,

Thanks very much for the tool as it is very helpufl. Just would like to state the issue I'm facing. I'm testing the validator on my windows machine which seems to be working perfectly. the simple method as the follwoing :

const validator = require('xsd-schema-validator');
var openScenario = fs.readFileSync('./Schemas/test.xosc','UTF8');

validator.validateXML(openScenario, './Schemas/OpenScenario-1-1/OpenSCENARIO.xsd', function (err :any, result : any) 
{

  if(err)
  {
    console.log(err)
    console.log(result)
    var jsonObject = JsonObject()
    // jsonObject["openScenario"].version = version;
    jsonObject["openScenario"].isOpenScenarioValid = result.valid;
    jsonObject["openScenario"].errorDetails = result.messages
  }
    var jsonResult = JSON.stringify(jsonObject,null, "\t")
    // fn(jsonResult)

});

The above code returns the desired result and both of the xml and xsd are working. However, once i wanted to docker my application using the following dockerfile, and without changing anything in the method, the validator stopped working: `

FROM node:18-slim

RUN apt-get update && apt-get -y upgrade && \
    apt-get install -y openjdk-11-jdk-headless && \
    apt-get clean ;

RUN java -version
RUN javac -version

ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
RUN export JAVA_HOME 

WORKDIR /code
EXPOSE 8443
COPY code/package.json .
RUN npm install

COPY code/. .

CMD ["node","app.js"] 

`

When I run my application i get the following message :

Error: invalid xml (status=WITH_ERRORS)
    at buildError (/code/node_modules/xsd-schema-validator/lib/validator.js:205:14)
    at finish (/code/node_modules/xsd-schema-validator/lib/validator.js:171:34)
    at ChildProcess.<anonymous> (/code/node_modules/xsd-schema-validator/lib/validator.js:214:7)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)
{ valid: false, result: 'WITH_ERRORS', messages: [] }

--

I've seen you ask people about node/java versions so I prepared that for you.

root@78d0c886dc22:/code# java -version openjdk version "11.0.18" 2023-01-17 OpenJDK Runtime Environment (build 11.0.18+10-post-Debian-1deb11u1) OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Debian-1deb11u1, mixed mode, sharing) root@78d0c886dc22:/code#node -v v18.14.0 root@78d0c886dc22:/code#javac -version javac 11.0.18 root@78d0c886dc22:/code# (dirname $(dirname $(readlink -f $(which javac)))) /usr/lib/jvm/java-11-openjdk-amd64

Would you please assist with that, I tried to use different java images as well but not working.?

vieira-avmb commented 1 year ago

Facing same issue. Working perfectly on windows machine but in my case erroring with FATAL_ERROR in docker with ubuntu.

nikku commented 1 year ago

Could you provide me with a docker image to reproduce the issue with?