6

I have VAST XML and validating it against vast 2.0.1 xsd. It throws following error:-

Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'VAST'

My VAST XML:-

<VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      version="2.0" 
      xsi:noNamespaceSchemaLocation="vast.xsd">
  <Ad id="11267375">
    <InLine>
      <AdSystem version="1.0">Sample vast</AdSystem>
      <AdTitle><![CDATA[AD_NFM3122HD.mov]]></AdTitle>
      <Description><![CDATA[<p>&nbsp;</p>]]></Description>
      <Creatives>
        <Creative sequence="1" AdID="" id="11267375">
          <Linear>
            <Duration>00:00:15</Duration>
          </Linear>
        </Creative>
      </Creatives>
    </InLine>
  </Ad>
</VAST>

VAST 2.0.1.xsd - https://github.com/chrisdinn/vast/blob/master/lib/vast_2.0.1.xsd

When I remove xsi:noNamespaceSchemaLocation="vast.xsd"> from my VAST Xml. Its working well.

Should I need to use this xsi:noNamespaceSchemaLocation="vast.xsd"> definitely. What is the use of it ?

What is the XSD filename I have to use in it instead of "vast.xsd" ?

I am running on java 1.8 and here is my stack trace

org.xml.sax.SAXParseException; cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'VAST'.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:452)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3230)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(XMLSchemaValidator.java:2707)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2050)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:740)
    at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.beginNode(DOMValidatorHelper.java:277)
    at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:244)
    at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:190)
    at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:109)
    at javax.xml.validation.Validator.validate(Validator.java:124)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.rules.Verifier$1.evaluate(Verifier.java:35)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
    at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:62)
    at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:139)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Galet
  • 5,853
  • 21
  • 82
  • 148

2 Answers2

1

Here is your XML repaired to be valid against the vast.xsd, which I've referenced remotely:

<VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      version="2.0" 
      xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/chrisdinn/vast/master/lib/vast_2.0.1.xsd">
  <Ad id="11267375">
    <InLine>
      <AdSystem version="1.0">Sample vast</AdSystem>
      <AdTitle><![CDATA[AD_NFM3122HD.mov]]></AdTitle>
      <Description><![CDATA[<p>&nbsp;</p>]]></Description>
      <Survey/>
      <Error/>
      <Impression/>
      <Creatives>
        <Creative sequence="1" AdID="" id="11267375">
          <Linear>
            <Duration>00:00:15</Duration>
          </Linear>
        </Creative>
      </Creatives>
    </InLine>
  </Ad>
</VAST>

I've added some elements required by the XSD, however even without such additions, you should not have been receiving an error complaining that

Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'VAST'

If you still receive that error with the above XML, please post a comment stating the software from which the error is originating.


Update: Still not working?

If you are specifying the location of the XSD in your Java code,

Schema schema = schemaFactory.newSchema(new URL(getSchemaURLString()));

but you wish to use xsi:noNamespaceSchemaLocation instead, try removing the Java-based specification of the XSD location:

Schema schema = schemaFactory.newSchema();
kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • I still receive an same error with above XML. I am running on java "1.8.0_72". My issue related to like this http://stackoverflow.com/questions/5080784/using-dom4j-domdocument-to-feed-validator-validatedomsource-fails-in-java-1-6. But i haven't tried in java 1.5 or lower than 1.8 – Galet Apr 20 '16 at 05:05
  • Answer updated. If this doesn't help, we'll need to see a [mcve]. Thanks. – kjhughes Apr 20 '16 at 14:32
0

This happened to me once because in the

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

part I had written http// instead of http://. Which suggests that the error was thrown when the validator couldn't find the namespace you I was referring to and was therefore be unable to validate the xsi:noNamespaceSchemaLocation attribute (since it's also in xsi).

If the namespace url is correct (and it does look correct in your xml) then it might suggest that it's the version that it can't find.

I would perhaps remove the version attribute (I don't know if there is a version 2.0), confirm that the version number is correct or use xsi:version as possible things to try if I were in this situation.

frezq
  • 653
  • 8
  • 18