I want to merge two xml files using xslt. 
Both the faces-config xml files have a faces-config tag. If I put the complete 
faces-config tag, the merge fails. Why?

the single faces-config tag is
<faces-config>

the complete faces-config tag is
<faces-config version="1.2"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns="http://java.sun.com/xml/ns/javaee";>

I call xslt-maven-plugin this way at my pom.xml

            <!-- faces-config merge -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>xslt-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>merge-faces-config</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>transform</goal>
                        </goals>
                        <configuration>
                            
<xslFile>${org.basegen.otherGen.dir}/xslt/mergeFacesConfig.xsl</xslFile>
                            <srcDir>${org.basegen.srcCustom.dir}/view/</srcDir>
                            
<destDir>${org.basegen.webGenerated.dir}/WEB-INF/</destDir>
                            <srcIncludes>faces-config-custom.xml</srcIncludes>
                            <fileNameRegex>faces-config-custom</fileNameRegex>
                            
<fileNameReplacement>faces-config</fileNameReplacement>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

the xslt file and the two xml files with single faces-config tab are attached.

thanks a lot in advance
´s marcelo



      
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
	version="1.0">

	<xsl:output method="xml" indent="yes"/>

	<!--load the merge file -->
	<xsl:variable name="facesGen"
		select="document('../../other/xslt/faces-config-gen.xml')" />

	<!-- combine the files -->

	<xsl:template match="/">

        <faces-config version="1.2" 
                      xmlns="http://java.sun.com/xml/ns/javaee"; 
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
                      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd";>

			<application>

				<!-- copy all the child nodes of the aplication tag in 
					the main file -->
				<xsl:for-each
					select="faces-config/application/child::*">
					<xsl:copy-of select="." />
				</xsl:for-each>

				<!-- and all the child nodes of the aplication tag in the 
					merge file -->
				<xsl:for-each
					select="$facesGen/faces-config/application/child::*">
					<xsl:copy-of select="." />
				</xsl:for-each>

			</application>

			<!-- copy all the converter tag in 
				the main file -->
			<xsl:for-each select="faces-config/converter">
				<xsl:copy-of select="." />
			</xsl:for-each>

			<!-- and all the converter tag in 
				merge file -->
			<xsl:for-each
				select="$facesGen/faces-config/converter">
				<xsl:copy-of select="." />
			</xsl:for-each>

			<!-- copy all the validator tag in 
				the main file -->
			<xsl:for-each select="faces-config/validator">
				<xsl:copy-of select="." />
			</xsl:for-each>

			<!-- and all the validator tag in 
				merge file -->
			<xsl:for-each
				select="$facesGen/faces-config/validator">
				<xsl:copy-of select="." />
			</xsl:for-each>

			<!-- copy all the lifecycle tag in 
				the main file -->
			<xsl:for-each select="faces-config/lifecycle">
				<xsl:copy-of select="." />
			</xsl:for-each>

			<!-- and all the lifecycle tag in 
				merge file -->
			<xsl:for-each
				select="$facesGen/faces-config/lifecycle">
				<xsl:copy-of select="." />
			</xsl:for-each>

			<!-- copy all the managed-bean tag in 
				the main file -->
			<xsl:for-each select="faces-config/managed-bean">
				<xsl:copy-of select="." />
			</xsl:for-each>

			<!-- and all the managed-bean tag in 
				merge file -->
			<xsl:for-each
				select="$facesGen/faces-config/managed-bean">
				<xsl:copy-of select="." />
			</xsl:for-each>

			<!-- copy all the navigation-rule tag in 
				the main file -->
			<xsl:for-each select="faces-config/navigation-rule">
				<xsl:if test="from-view-id!='*'">
					<xsl:copy-of select="." />
				</xsl:if>
			</xsl:for-each>

			<!-- and all the navigation-rule tag in 
				merge file -->
			<xsl:for-each
				select="$facesGen/faces-config/navigation-rule">
				<xsl:if test="from-view-id!='*'">
					<xsl:copy-of select="." />
				</xsl:if>
			</xsl:for-each>

			<!-- merge the navigation-rule tag for 
				from-view-id=* -->
			<xsl:for-each
				select="$facesGen/faces-config/navigation-rule">
				<xsl:if test="from-view-id='*'">
					<xsl:variable name="from-view-id">
						<xsl:value-of select="from-view-id" />
					</xsl:variable>

					<navigation-rule>
						<from-view-id>*</from-view-id>

						<xsl:copy-of select="navigation-case" />

						<xsl:copy-of
							select="/faces-config/navigation-rule[from-view-id=$from-view-id]/navigation-case" />
							
					</navigation-rule>
				</xsl:if>
			</xsl:for-each>
		</faces-config>
	</xsl:template>

</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
    <application>
        <!-- message bundle -->
        <message-bundle>org.basegen.base.view.Messages</message-bundle>

        <!-- Spring JSF -->
        <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>

        <!-- default pt_BR locale -->
        <locale-config>
            <default-locale>pt_BR</default-locale>
            <supported-locale>en_US</supported-locale>
            <supported-locale>pt_BR</supported-locale>
        </locale-config>

        <!-- resource bundles -->
        <resource-bundle>
            <base-name>com.acme.teste.view.msgcustom-teste</base-name>
            <var>msgcustomteste</var>
        </resource-bundle>
    </application>

    <lifecycle>
	   <phase-listener>org.basegen.base.view.jsf.event.MessageListener</phase-listener>
    </lifecycle>

    <converter>
      <converter-id>base.EncryptConverter</converter-id>	
      <converter-class>org.basegen.base.view.jsf.converter.EncryptConverter</converter-class>
    </converter>

    <!-- com.acme.teste.security -->
    <managed-bean>
        <managed-bean-name>passwordPageBean</managed-bean-name>
        <managed-bean-class>com.acme.teste.security.view.bean.PasswordPageBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>

        <managed-bean>
            <managed-bean-name>userPageBean</managed-bean-name>
            <managed-bean-class>com.acme.teste.security.view.bean.UserPageBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
            <managed-bean>
            <managed-bean-name>userListPageBean</managed-bean-name>
            <managed-bean-class>com.acme.teste.security.view.bean.UserListPageBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
            
        <managed-bean>
            <managed-bean-name>profilePageBean</managed-bean-name>
            <managed-bean-class>com.acme.teste.security.view.bean.ProfilePageBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
            <managed-bean>
            <managed-bean-name>profileListPageBean</managed-bean-name>
            <managed-bean-class>com.acme.teste.security.view.bean.ProfileListPageBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
                <managed-bean>
            <managed-bean-name>profileAddManyPageBean</managed-bean-name>
            <managed-bean-class>com.acme.teste.security.view.bean.ProfileAddManyPageBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
        
        <managed-bean>
            <managed-bean-name>permissionPageBean</managed-bean-name>
            <managed-bean-class>com.acme.teste.security.view.bean.PermissionPageBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
            

        <navigation-rule>
            <from-view-id>/pages/security/userViewConfirm.xhtml</from-view-id>
            <navigation-case>
                <from-outcome>success</from-outcome>
                <to-view-id>/pages/success.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
            <navigation-case>
                <from-outcome>back</from-outcome>
                <to-view-id>/pages/security/userList.xhtml</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>edit</from-outcome>
                <to-view-id>/pages/security/userInsertUpdate.xhtml</to-view-id>
            </navigation-case>
			                                                                                                    <navigation-case>
                            <from-outcome>viewProfile</from-outcome>
                            <to-view-id>/pages/security/profileViewConfirm.xhtml</to-view-id>
                        </navigation-case>	
                                                                                            <navigation-case>
                        <from-outcome>profileInsertUpdate</from-outcome>
                        <to-view-id>/pages/security/profileInsertUpdate.xhtml</to-view-id>
                    </navigation-case>
                    <navigation-case>
                        <from-outcome>profileViewConfirm</from-outcome>
                        <to-view-id>/pages/security/profileViewConfirm.xhtml</to-view-id>
                    </navigation-case>
                                                                            </navigation-rule>
        <navigation-rule>
            <from-view-id>/pages/security/userList.xhtml</from-view-id>
            <navigation-case>
                <from-outcome>view</from-outcome>
                <to-view-id>/pages/security/userViewConfirm.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
            <navigation-case>
                <from-outcome>edit</from-outcome>
                <to-view-id>/pages/security/userInsertUpdate.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
            <navigation-case>
                <from-outcome>remove</from-outcome>
                <to-view-id>/pages/security/userViewConfirm.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
                            <navigation-case>
                    <from-outcome>modifyState</from-outcome>
                    <to-view-id>/pages/security/userViewConfirm.xhtml</to-view-id>
                    <redirect/>
                </navigation-case>
                        <navigation-case>
                <from-outcome>insertNewUser</from-outcome>
                <to-view-id>/pages/security/userInsertUpdate.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
                                                                                                                                                                                                                                                                                                                                                                                            </navigation-rule>
        <navigation-rule>
        <from-view-id>/pages/security/userViewConfirm.xhtml</from-view-id>
                                                                                                                                                                                        </navigation-rule>

                    <navigation-rule>
            <from-view-id>/pages/security/profileInsertUpdate.xhtml</from-view-id>
            <navigation-case>
                <from-outcome>success</from-outcome>
                <to-view-id>/pages/success.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
            <navigation-case>
                <from-outcome>error</from-outcome>
                <to-view-id>/pages/security/profileInsertUpdate.xhtml</to-view-id>
            </navigation-case>        
            <navigation-case>
                <from-outcome>back</from-outcome>
                <to-view-id>/pages/security/profileList.xhtml</to-view-id>
            </navigation-case>
                                                <navigation-case>
                        <from-outcome>addPermission</from-outcome>
                        <to-view-id>/pages/security/permissionInsertUpdate.xhtml</to-view-id>
                    </navigation-case>
                    <navigation-case>
                        <from-outcome>editPermission</from-outcome>
                        <to-view-id>/pages/security/permissionInsertUpdate.xhtml</to-view-id>
                    </navigation-case>
                    <navigation-case>
                        <from-outcome>viewPermission</from-outcome>
                        <to-view-id>/pages/security/permissionViewConfirm.xhtml</to-view-id>
                    </navigation-case>            
                                                                                                </navigation-rule>
        <navigation-rule>
            <from-view-id>/pages/security/profileViewConfirm.xhtml</from-view-id>
            <navigation-case>
                <from-outcome>success</from-outcome>
                <to-view-id>/pages/success.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
            <navigation-case>
                <from-outcome>back</from-outcome>
                <to-view-id>/pages/security/profileList.xhtml</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>edit</from-outcome>
                <to-view-id>/pages/security/profileInsertUpdate.xhtml</to-view-id>
            </navigation-case>
			                                                                                <navigation-case>
                            <from-outcome>viewPermission</from-outcome>
                            <to-view-id>/pages/security/permissionViewConfirm.xhtml</to-view-id>
                        </navigation-case>
                                                                                                                                                                                        <navigation-case>
                            <from-outcome>viewUser</from-outcome>
                            <to-view-id>/pages/security/userViewConfirm.xhtml</to-view-id>
                        </navigation-case>	
                                                                                            <navigation-case>
                        <from-outcome>userInsertUpdate</from-outcome>
                        <to-view-id>/pages/security/userInsertUpdate.xhtml</to-view-id>
                    </navigation-case>
                    <navigation-case>
                        <from-outcome>userViewConfirm</from-outcome>
                        <to-view-id>/pages/security/userViewConfirm.xhtml</to-view-id>
                    </navigation-case>
                                                                            </navigation-rule>
        <navigation-rule>
            <from-view-id>/pages/security/profileList.xhtml</from-view-id>
            <navigation-case>
                <from-outcome>view</from-outcome>
                <to-view-id>/pages/security/profileViewConfirm.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
            <navigation-case>
                <from-outcome>edit</from-outcome>
                <to-view-id>/pages/security/profileInsertUpdate.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
            <navigation-case>
                <from-outcome>remove</from-outcome>
                <to-view-id>/pages/security/profileViewConfirm.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
                            <navigation-case>
                    <from-outcome>modifyState</from-outcome>
                    <to-view-id>/pages/security/profileViewConfirm.xhtml</to-view-id>
                    <redirect/>
                </navigation-case>
                        <navigation-case>
                <from-outcome>insertNewProfile</from-outcome>
                <to-view-id>/pages/security/profileInsertUpdate.xhtml</to-view-id>
                <redirect/>
            </navigation-case>
                                                                                                                                                                                                                                                                    </navigation-rule>
        <navigation-rule>
        <from-view-id>/pages/security/profileViewConfirm.xhtml</from-view-id>
                                                                                                                                                                                        </navigation-rule>

                <navigation-rule>
            <from-view-id>/pages/security/profileAddMany.xhtml</from-view-id>
            <navigation-case>
                <from-outcome>error</from-outcome>
                <to-view-id>/pages/security/profileAddMany.xhtml</to-view-id>
            </navigation-case>                
                                                                            <navigation-case>
                                <from-outcome>userInsertUpdate</from-outcome>
                                <to-view-id>/pages/security/userInsertUpdate.xhtml</to-view-id>
                            </navigation-case>
                                                                                                                                                                                                                            </navigation-rule>
                <navigation-rule>
            <from-view-id>/pages/security/permissionInsertUpdate.xhtml</from-view-id>
            <navigation-case>
                <from-outcome>error</from-outcome>
                <to-view-id>/pages/security/permissionInsertUpdate.xhtml</to-view-id>
            </navigation-case>        

                                                                                                                                        <navigation-case>
                            <from-outcome>profileInsertUpdate</from-outcome>
                            <to-view-id>/pages/security/profileInsertUpdate.xhtml</to-view-id>
                        </navigation-case>
                        <navigation-case>
                            <from-outcome>profileViewConfirm</from-outcome>
                            <to-view-id>/pages/security/profileViewConfirm.xhtml</to-view-id>
                        </navigation-case>
                                                                                                                                                            </navigation-rule>
        <navigation-rule>
        <from-view-id>/pages/security/permissionViewConfirm.xhtml</from-view-id>
                                                                                                        <navigation-case>
                        <from-outcome>profileInsertUpdate</from-outcome>
                        <to-view-id>/pages/security/profileInsertUpdate.xhtml</to-view-id>
                    </navigation-case>
                    <navigation-case>
                        <from-outcome>profileViewConfirm</from-outcome>
                        <to-view-id>/pages/security/profileViewConfirm.xhtml</to-view-id>
                    </navigation-case>
                                                                                                                    </navigation-rule>

        
    <!-- Navigation Rules for all pages -->
    <navigation-rule>
        <from-view-id>*</from-view-id>
        <navigation-case>
            <from-outcome>main</from-outcome>
            <to-view-id>/pages/blank.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>success-page</from-outcome>
            <to-view-id>/pages/success.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
        <navigation-case>
            <from-outcome>error</from-outcome>
            <to-view-id>/pages/error.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>error-page</from-outcome>
            <to-view-id>/pages/error.xhtml</to-view-id>
            <redirect/>
        </navigation-case>        

        <!-- com.acme.teste.security -->
        <navigation-case>
            <from-outcome>changePassword</from-outcome>
            <to-view-id>/pages/security/changePassword.xhtml</to-view-id>
        </navigation-case>

                                    <navigation-case>
                    <from-outcome>viewUser</from-outcome>
                    <to-view-id>/pages/security/userViewConfirm.xhtml</to-view-id>
                </navigation-case> 
                <navigation-case>
                    <from-outcome>insertNewUser</from-outcome>
                    <to-view-id>/pages/security/userInsertUpdate.xhtml</to-view-id>
                </navigation-case>
                <navigation-case>
                    <from-outcome>userList</from-outcome>
                    <to-view-id>/pages/security/userList.xhtml</to-view-id>
                </navigation-case>
                                                                <navigation-case>
                    <from-outcome>viewProfile</from-outcome>
                    <to-view-id>/pages/security/profileViewConfirm.xhtml</to-view-id>
                </navigation-case> 
                <navigation-case>
                    <from-outcome>insertNewProfile</from-outcome>
                    <to-view-id>/pages/security/profileInsertUpdate.xhtml</to-view-id>
                </navigation-case>
                <navigation-case>
                    <from-outcome>profileList</from-outcome>
                    <to-view-id>/pages/security/profileList.xhtml</to-view-id>
                </navigation-case>
                                                            </navigation-rule>

    <!-- com.acme.teste.security -->
    <navigation-rule>
        <from-view-id>/pages/security/changePassword.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/pages/success.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>error</from-outcome>
            <to-view-id>/pages/security/changePassword.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>back</from-outcome>
            <to-view-id>/pages/blank.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
</faces-config>
<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
    <managed-bean>
        <managed-bean-name>xxxxxPageBean</managed-bean-name>
        <managed-bean-class>ppppp.XxxxxxPageBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>

    <navigation-rule>
        <from-view-id>*</from-view-id>
        <navigation-case>
            <from-outcome>xxxxxxxx</from-outcome>
            <to-view-id>/pages/xxxxxxxxx.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
</faces-config>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to