10 Replies Latest reply on Aug 11, 2009 2:35 PM by christian.bauer

    components.xml and include

    nico.ben

      Hi,
      I am trying to have a components.xml divided in modules to obtain:




      **** components.xml *****
      ...
      <ui:include src="components_events.xml"/>
      <ui:include src="components_rules.xml"/>
      ...
      *************************





      and put events and rules in another xml file.


      But ui:include doesn't work.
      Is there a way to do that, please?


      Thank you,
      Nicola

        • 1. Re: components.xml and include
          lvdberg

          Hi,


          This is something which can be done in Spring, but not (yet) in Seam. Besides that you're using the Facelets namespace (ui), which supports something like this for the inclusion of page (-parts).


          You can have different components.xml in different jars, but I don't think its what you want to do.


          Leo

          • 2. Re: components.xml and include
            christian.bauer

            Use XML includes/entities. If you don't know how that works, learn XML.


            • 3. Re: components.xml and include
              lvdberg

              IBM has a nice website about XML and includes, but I repeat its not the same as Spring offers.


              http://www.ibm.com/developerworks/xml/library/x-tipgentity.html


              Success,


              Leo


              P.S. Seam is already complex enough and we hoped we could forget XML a bit. A push in the right direction will keep people interested


              • 4. Re: components.xml and include
                acerberus

                It would however be really nice if it was supported in Seam directly since with a growing number of components the components.xml file gets quite messy.


                The easiest way I can imagine to achieve this is to allow for XIncludes. This would probably just mean setting a flag for the XML Parser that is used to read in the components.xml file.


                Cheers
                Arno

                • 5. Re: components.xml and include
                  nico.ben

                  I opened a jira request for that


                  https://jira.jboss.org/jira/browse/JBSEAM-4286


                  BYe
                  Nic

                  • 6. Re: components.xml and include
                    torakuma

                    I would also like to do this so I tried out include/entity and was not able to get it to work.


                    My components.xml has:


                    <!DOCTYPE components [ 
                         <!ENTITY components2 SYSTEM "./components2.xml">
                    ]>



                    ... and I reference the include as




                    &components2;




                    However I get the following error:



                    Caused by: java.lang.RuntimeException: Can't find schema/DTD reference: C:\jboss-4.2.3.GA\bin\components2.xml
                            at org.jboss.seam.util.XML.getRootElement(XML.java:29)
                            at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:227)
                            ... 138 more
                    Caused by: org.dom4j.DocumentException: C:\jboss-4.2.3.GA\bin\components2.xml Nested exception: C:\jboss-4.2.3.GA\bin\components2.xml
                            at org.dom4j.io.SAXReader.read(SAXReader.java:484)
                            at org.dom4j.io.SAXReader.read(SAXReader.java:343)
                            at org.jboss.seam.util.XML.getRootElement(XML.java:24)
                            ... 139 more




                    It looks as though it is looking from the JBOSS bin directory!  Shouldn't it find it at the same location as components.xml since I use ./?



                    • 7. Re: components.xml and include
                      torakuma

                      Can anyone recommend the proper way to include?

                      • 8. Re: components.xml and include
                        asookazian

                        I tried using <xi:include> and failed.


                        Spring does it (see below).  We need an <import> tag in Seam as well.



                        An alternate approach is to use one or more occurrences of the <import/> element to load bean definitions from another file (or files). Let's look at a sample:

                        <beans>
                        
                            <import resource="services.xml"/>
                            <import resource="resources/messageSource.xml"/>
                            <import resource="/resources/themeSource.xml"/>
                        
                            <bean id="bean1" class="..."/>
                            <bean id="bean2" class="..."/>
                        
                        </beans>




                        In this example, external bean definitions are being loaded from 3 files, services.xml, messageSource.xml, and themeSource.xml. All location paths are considered relative to the definition file doing the importing, so services.xml in this case must be in the same directory or classpath location as the file doing the importing, while messageSource.xml and themeSource.xml must be in a resources location below the location of the importing file. As you can see, a leading slash is actually ignored, but given that these are considered relative paths, it is probably better form not to use the slash at all.

                        The contents of the files being imported must be fully valid XML bean definition files according to the Schema or DTD, including the top level <beans/> element.

                        http://static.springsource.org/spring/docs/2.0.x/reference/beans.html

                        • 9. Re: components.xml and include
                          torakuma

                          Can the Seam gods weigh in on this?  Our project is getting quite large now and component configuration is becoming a headache since components.xml is so large.

                          • 10. Re: components.xml and include
                            christian.bauer