Artem St created CAMEL-11508:
--------------------------------

             Summary: Why "from" xml element does not support custom attributes 
in spring xml?
                 Key: CAMEL-11508
                 URL: https://issues.apache.org/jira/browse/CAMEL-11508
             Project: Camel
          Issue Type: Improvement
          Components: camel-spring
    Affects Versions: 2.19.1
            Reporter: Artem St


Hello,

The definition of "from" element in camel-spring.xsd does not allow to use a 
custom attributes, because of there is no declared anyAttribute element.

There is my route:
        <route id="722b2c5f">
            <from yuo:custom-attr="my custom attribute" 
uri="localmq://queueStart" />
            <to yuo:custom-attr="my custom attribute" uri="localmq://queue"/>
        </route>

And Camel gives me exception on that route:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 47 
in XML document from file [C:\Projects\server\main.xml] is invalid; nested 
exception is org.xml.sax.SAXParseException; lineNumber: 47; columnNumber: 83; 
cvc-complex-type.3.2.2: Attribute 'yuo:custom-attr' is not allowed to appear in 
element 'from'.
        at 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399)
        at 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
        at 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
        at 
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
        at 
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
        at 
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
        at 
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)
        at 
org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
        at 
org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
        at 
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
        at 
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:613)
        at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:514)
....
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 
'yuo:custom-attr' is not allowed to appear in element 'from'.
        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.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown
 Source)
        at 
org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
        at 
org.apache.xerces.impl.xs.XMLSchemaValidator.processAttributes(Unknown Source)
        at 
org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
        at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
Source)
        at 
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
 Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at 
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
        at 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:429)
        at 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)

My opinion is that "from" element should allow to create user specific 
attributes same as "to" element (which has a  <xs:anyAttribute 
namespace="##other" processContents="skip"/>
 in the definition)



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to