You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Ernst (JIRA)" <xe...@xml.apache.org> on 2012/05/02 11:24:50 UTC

[jira] [Created] (XERCESJ-1560) Facet Validation Fails while Serializing with CDATA elements

Michael Ernst created XERCESJ-1560:
--------------------------------------

             Summary: Facet Validation Fails while Serializing with CDATA elements
                 Key: XERCESJ-1560
                 URL: https://issues.apache.org/jira/browse/XERCESJ-1560
             Project: Xerces2-J
          Issue Type: Bug
          Components: JAXP (javax.xml.validation)
    Affects Versions: 2.10.0
            Reporter: Michael Ernst
         Attachments: testproject.zip

While marshalling a document with JAXB, I get the following error: [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
The document itself is valid when I parse it from a file. I tried it with DOM and SAX.

I attached a simple maven test project. Executing the main class {{TestJaxbValidate}} creates the following exception.

{noformat}
Exception in thread "main" javax.xml.bind.MarshalException
 - with linked exception:
[org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326)
	at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
	at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
	at TestJaxbValidate.main(TestJaxbValidate.java:23)
Caused by: org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
	at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.endElement(Unknown Source)
	at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
	at com.sun.xml.bind.v2.runtime.output.SAXOutput.endTag(SAXOutput.java:132)
	at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.endTag(XmlOutputAbstractImpl.java:124)
	at com.sun.xml.bind.v2.runtime.output.ForkXmlOutput.endTag(ForkXmlOutput.java:91)
	at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.endElement(NamespaceContextImpl.java:504)
	at com.sun.xml.bind.v2.runtime.XMLSerializer.endElement(XMLSerializer.java:315)
	at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:345)
	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1052)
	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1031)
	at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256)
	at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:129)
	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:161)
	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
	... 3 more{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Issue Comment Edited] (XERCESJ-1560) Facet Validation Fails while Serializing with CDATA elements

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13272531#comment-13272531 ] 

Michael Glavassevich edited comment on XERCESJ-1560 at 5/10/12 5:40 PM:
------------------------------------------------------------------------

XmlAdapters in JAXB transform a value from one form to another. In your case what you're returning is interpreted as an xs:string value with those exact characters.

There's no (standard) setting on a JAXB Marshaller which would coerce it to write CDATA sections. You could write an XMLStreamWriter [1] wrapper which transforms writeCharacters() calls to writeCData() and pass that to the Marshaller instead of relying on its default serialization behaviour. A SAX filter should work too.

Thanks.

[1] http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/stream/XMLStreamWriter.html
                
      was (Author: mrglavas@ca.ibm.com):
    XmlAdapters in JAXB transform a value from one form to another. In your case what you're returning is interpreted as an xs:string value with those exact characters.

There's no (standard) setting on a JAXB Marshaller which would coerce it to write CDATA sections. You could write an XMLStreamWriter [1] wrapper which transforms writeCharacters() calls to writeCData() and pass that to the Marshaller instead of relying on its default serialization behaviour. A SAX filter should work too.

Thanks.

[1] http://w3.hursley.ibm.com/java/docs/java6/api/javax/xml/stream/XMLStreamWriter.html
                  
> Facet Validation Fails while Serializing with CDATA elements
> ------------------------------------------------------------
>
>                 Key: XERCESJ-1560
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1560
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: JAXP (javax.xml.validation)
>    Affects Versions: 2.10.0
>            Reporter: Michael Ernst
>         Attachments: testproject.zip
>
>
> While marshalling a document with JAXB, I get the following error: [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> The document itself is valid when I parse it from a file. I tried it with DOM and SAX.
> I attached a simple maven test project. Executing the main class {{TestJaxbValidate}} creates the following exception.
> {noformat}
> Exception in thread "main" javax.xml.bind.MarshalException
>  - with linked exception:
> [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
> 	at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
> 	at TestJaxbValidate.main(TestJaxbValidate.java:23)
> Caused by: org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.
> 	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
> 	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
> 	at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.endElement(Unknown Source)
> 	at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
> 	at com.sun.xml.bind.v2.runtime.output.SAXOutput.endTag(SAXOutput.java:132)
> 	at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.endTag(XmlOutputAbstractImpl.java:124)
> 	at com.sun.xml.bind.v2.runtime.output.ForkXmlOutput.endTag(ForkXmlOutput.java:91)
> 	at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.endElement(NamespaceContextImpl.java:504)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.endElement(XMLSerializer.java:315)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:345)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1052)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1031)
> 	at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256)
> 	at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:129)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:161)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
> 	... 3 more{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Commented] (XERCESJ-1560) Facet Validation Fails while Serializing with CDATA elements

Posted by "Michael Ernst (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13273067#comment-13273067 ] 

Michael Ernst commented on XERCESJ-1560:
----------------------------------------

Thanks for the tip. I already found the working solution with the XMLStreamWriter which works very well. I postet the solution also in a related question on stackoverflow (http://stackoverflow.com/questions/3136375/how-to-generate-cdata-block-using-jaxb).
                
> Facet Validation Fails while Serializing with CDATA elements
> ------------------------------------------------------------
>
>                 Key: XERCESJ-1560
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1560
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: JAXP (javax.xml.validation)
>    Affects Versions: 2.10.0
>            Reporter: Michael Ernst
>         Attachments: testproject.zip
>
>
> While marshalling a document with JAXB, I get the following error: [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> The document itself is valid when I parse it from a file. I tried it with DOM and SAX.
> I attached a simple maven test project. Executing the main class {{TestJaxbValidate}} creates the following exception.
> {noformat}
> Exception in thread "main" javax.xml.bind.MarshalException
>  - with linked exception:
> [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
> 	at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
> 	at TestJaxbValidate.main(TestJaxbValidate.java:23)
> Caused by: org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.
> 	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
> 	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
> 	at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.endElement(Unknown Source)
> 	at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
> 	at com.sun.xml.bind.v2.runtime.output.SAXOutput.endTag(SAXOutput.java:132)
> 	at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.endTag(XmlOutputAbstractImpl.java:124)
> 	at com.sun.xml.bind.v2.runtime.output.ForkXmlOutput.endTag(ForkXmlOutput.java:91)
> 	at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.endElement(NamespaceContextImpl.java:504)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.endElement(XMLSerializer.java:315)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:345)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1052)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1031)
> 	at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256)
> 	at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:129)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:161)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
> 	... 3 more{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Issue Comment Edited] (XERCESJ-1560) Facet Validation Fails while Serializing with CDATA elements

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13272531#comment-13272531 ] 

Michael Glavassevich edited comment on XERCESJ-1560 at 5/10/12 5:38 PM:
------------------------------------------------------------------------

XmlAdapters in JAXB transform a value from one form to another. In your case what you're returning is interpreted as an xs:string value with those exact characters.

There's no (standard) setting on a JAXB Marshaller which would coerce it to write CDATA sections. You could write an XMLStreamWriter [1] wrapper which transforms writeCharacters() calls to writeCData() and pass that to the Marshaller instead of relying on its default serialization behaviour. A SAX filter should work too.

Thanks.

[1] http://w3.hursley.ibm.com/java/docs/java6/api/javax/xml/stream/XMLStreamWriter.html
                
      was (Author: mrglavas@ca.ibm.com):
    XmlAdapters in JAXB transform a value from one from to another. In your case what you're returning is interpreted as an xs:string value with those exact characters.

There's no (standard) setting on a JAXB Marshaller which would coerce it to write CDATA sections. You could write an XMLStreamWriter [1] wrapper which transforms writeCharacters() calls to writeCData() and pass that to the Marshaller instead of relying on its default serialization behaviour. A SAX filter should work too.

Thanks.

[1] http://w3.hursley.ibm.com/java/docs/java6/api/javax/xml/stream/XMLStreamWriter.html
                  
> Facet Validation Fails while Serializing with CDATA elements
> ------------------------------------------------------------
>
>                 Key: XERCESJ-1560
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1560
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: JAXP (javax.xml.validation)
>    Affects Versions: 2.10.0
>            Reporter: Michael Ernst
>         Attachments: testproject.zip
>
>
> While marshalling a document with JAXB, I get the following error: [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> The document itself is valid when I parse it from a file. I tried it with DOM and SAX.
> I attached a simple maven test project. Executing the main class {{TestJaxbValidate}} creates the following exception.
> {noformat}
> Exception in thread "main" javax.xml.bind.MarshalException
>  - with linked exception:
> [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
> 	at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
> 	at TestJaxbValidate.main(TestJaxbValidate.java:23)
> Caused by: org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.
> 	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
> 	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
> 	at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.endElement(Unknown Source)
> 	at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
> 	at com.sun.xml.bind.v2.runtime.output.SAXOutput.endTag(SAXOutput.java:132)
> 	at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.endTag(XmlOutputAbstractImpl.java:124)
> 	at com.sun.xml.bind.v2.runtime.output.ForkXmlOutput.endTag(ForkXmlOutput.java:91)
> 	at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.endElement(NamespaceContextImpl.java:504)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.endElement(XMLSerializer.java:315)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:345)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1052)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1031)
> 	at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256)
> 	at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:129)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:161)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
> 	... 3 more{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Updated] (XERCESJ-1560) Facet Validation Fails while Serializing with CDATA elements

Posted by "Michael Ernst (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1560?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Ernst updated XERCESJ-1560:
-----------------------------------

    Attachment: testproject.zip
    
> Facet Validation Fails while Serializing with CDATA elements
> ------------------------------------------------------------
>
>                 Key: XERCESJ-1560
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1560
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: JAXP (javax.xml.validation)
>    Affects Versions: 2.10.0
>            Reporter: Michael Ernst
>         Attachments: testproject.zip
>
>
> While marshalling a document with JAXB, I get the following error: [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> The document itself is valid when I parse it from a file. I tried it with DOM and SAX.
> I attached a simple maven test project. Executing the main class {{TestJaxbValidate}} creates the following exception.
> {noformat}
> Exception in thread "main" javax.xml.bind.MarshalException
>  - with linked exception:
> [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
> 	at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
> 	at TestJaxbValidate.main(TestJaxbValidate.java:23)
> Caused by: org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.
> 	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
> 	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
> 	at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.endElement(Unknown Source)
> 	at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
> 	at com.sun.xml.bind.v2.runtime.output.SAXOutput.endTag(SAXOutput.java:132)
> 	at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.endTag(XmlOutputAbstractImpl.java:124)
> 	at com.sun.xml.bind.v2.runtime.output.ForkXmlOutput.endTag(ForkXmlOutput.java:91)
> 	at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.endElement(NamespaceContextImpl.java:504)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.endElement(XMLSerializer.java:315)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:345)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1052)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1031)
> 	at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256)
> 	at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:129)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:161)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
> 	... 3 more{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Resolved] (XERCESJ-1560) Facet Validation Fails while Serializing with CDATA elements

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESJ-1560?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Glavassevich resolved XERCESJ-1560.
-------------------------------------------

    Resolution: Invalid

Usage error. You are literally making the element's value '<![CDATA[foo]]>'. That is not a CDATA section.
                
> Facet Validation Fails while Serializing with CDATA elements
> ------------------------------------------------------------
>
>                 Key: XERCESJ-1560
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1560
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: JAXP (javax.xml.validation)
>    Affects Versions: 2.10.0
>            Reporter: Michael Ernst
>         Attachments: testproject.zip
>
>
> While marshalling a document with JAXB, I get the following error: [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> The document itself is valid when I parse it from a file. I tried it with DOM and SAX.
> I attached a simple maven test project. Executing the main class {{TestJaxbValidate}} creates the following exception.
> {noformat}
> Exception in thread "main" javax.xml.bind.MarshalException
>  - with linked exception:
> [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
> 	at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
> 	at TestJaxbValidate.main(TestJaxbValidate.java:23)
> Caused by: org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.
> 	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
> 	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
> 	at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.endElement(Unknown Source)
> 	at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
> 	at com.sun.xml.bind.v2.runtime.output.SAXOutput.endTag(SAXOutput.java:132)
> 	at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.endTag(XmlOutputAbstractImpl.java:124)
> 	at com.sun.xml.bind.v2.runtime.output.ForkXmlOutput.endTag(ForkXmlOutput.java:91)
> 	at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.endElement(NamespaceContextImpl.java:504)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.endElement(XMLSerializer.java:315)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:345)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1052)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1031)
> 	at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256)
> 	at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:129)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:161)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
> 	... 3 more{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Commented] (XERCESJ-1560) Facet Validation Fails while Serializing with CDATA elements

Posted by "Michael Ernst (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13268304#comment-13268304 ] 

Michael Ernst commented on XERCESJ-1560:
----------------------------------------

Ok, thanks for the clarification. I thought the value has to be interpreted as CDATA.
                
> Facet Validation Fails while Serializing with CDATA elements
> ------------------------------------------------------------
>
>                 Key: XERCESJ-1560
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1560
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: JAXP (javax.xml.validation)
>    Affects Versions: 2.10.0
>            Reporter: Michael Ernst
>         Attachments: testproject.zip
>
>
> While marshalling a document with JAXB, I get the following error: [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> The document itself is valid when I parse it from a file. I tried it with DOM and SAX.
> I attached a simple maven test project. Executing the main class {{TestJaxbValidate}} creates the following exception.
> {noformat}
> Exception in thread "main" javax.xml.bind.MarshalException
>  - with linked exception:
> [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
> 	at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
> 	at TestJaxbValidate.main(TestJaxbValidate.java:23)
> Caused by: org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.
> 	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
> 	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
> 	at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.endElement(Unknown Source)
> 	at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
> 	at com.sun.xml.bind.v2.runtime.output.SAXOutput.endTag(SAXOutput.java:132)
> 	at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.endTag(XmlOutputAbstractImpl.java:124)
> 	at com.sun.xml.bind.v2.runtime.output.ForkXmlOutput.endTag(ForkXmlOutput.java:91)
> 	at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.endElement(NamespaceContextImpl.java:504)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.endElement(XMLSerializer.java:315)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:345)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1052)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1031)
> 	at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256)
> 	at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:129)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:161)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
> 	... 3 more{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


[jira] [Commented] (XERCESJ-1560) Facet Validation Fails while Serializing with CDATA elements

Posted by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XERCESJ-1560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13272531#comment-13272531 ] 

Michael Glavassevich commented on XERCESJ-1560:
-----------------------------------------------

XmlAdapters in JAXB transform a value from one from to another. In your case what you're returning is interpreted as an xs:string value with those exact characters.

There's no (standard) setting on a JAXB Marshaller which would coerce it to write CDATA sections. You could write an XMLStreamWriter [1] wrapper which transforms writeCharacters() calls to writeCData() and pass that to the Marshaller instead of relying on its default serialization behaviour. A SAX filter should work too.

Thanks.

[1] http://w3.hursley.ibm.com/java/docs/java6/api/javax/xml/stream/XMLStreamWriter.html
                
> Facet Validation Fails while Serializing with CDATA elements
> ------------------------------------------------------------
>
>                 Key: XERCESJ-1560
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1560
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: JAXP (javax.xml.validation)
>    Affects Versions: 2.10.0
>            Reporter: Michael Ernst
>         Attachments: testproject.zip
>
>
> While marshalling a document with JAXB, I get the following error: [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> The document itself is valid when I parse it from a file. I tried it with DOM and SAX.
> I attached a simple maven test project. Executing the main class {{TestJaxbValidate}} creates the following exception.
> {noformat}
> Exception in thread "main" javax.xml.bind.MarshalException
>  - with linked exception:
> [org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.]
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
> 	at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
> 	at TestJaxbValidate.main(TestJaxbValidate.java:23)
> Caused by: org.xml.sax.SAXParseException: cvc-maxLength-valid: Value '<![CDATA[foo]]>' with length = '15' is not facet-valid with respect to maxLength '3' for type '#AnonType_test'.
> 	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
> 	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
> 	at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.endElement(Unknown Source)
> 	at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
> 	at com.sun.xml.bind.v2.runtime.output.SAXOutput.endTag(SAXOutput.java:132)
> 	at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.endTag(XmlOutputAbstractImpl.java:124)
> 	at com.sun.xml.bind.v2.runtime.output.ForkXmlOutput.endTag(ForkXmlOutput.java:91)
> 	at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.endElement(NamespaceContextImpl.java:504)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.endElement(XMLSerializer.java:315)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.leafElement(XMLSerializer.java:345)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1052)
> 	at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$StringImplImpl.writeLeafElement(RuntimeBuiltinLeafInfoImpl.java:1031)
> 	at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(TransducedAccessor.java:256)
> 	at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(SingleElementLeafProperty.java:129)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:161)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
> 	at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
> 	... 3 more{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org