Update:

I changed the code to this:
  public void merge(
    FacesConfigBean owner,
    URL             url) throws MojoExecutionException
  {
    try
    {
      URLConnection conn = url.openConnection();
      long lastModified = conn.getLastModified();

      // Establish the current last-modified value
      // As new components are added, they will remember
      // this current value as their own last-modified
      owner.touch(lastModified);

      Digester digester = createDigester();
      digester.push(url);
      digester.push(owner);
      digester.parse(url.toExternalForm());
    }

Now the path is correct:
resolveEntity('null',
'file:/home/anrobins/development/maven-trinidad/branches/2.0.0-branch/maven-faces-plugin/target/test-classes/META-INF/maven-faces-plugin/components/trinidad/faces/TestInclude.xml')

testGenerate(org.apache.myfaces.trinidadbuild.plugin.faces.GenerateComponentsMojoTest)
 Time elapsed: 0.359 sec  <<< ERROR!
org.apache.maven.plugin.MojoExecutionException: Failed to parse
file:/home/anrobins/development/maven-trinidad/branches/2.0.0-branch/maven-faces-plugin/target/test-classes/META-INF/maven-faces-plugin/components/trinidad/faces/Command.xml
        at 
org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacesConfigParser.merge(FacesConfigParser.java:68)
        at 
org.apache.myfaces.trinidadbuild.plugin.faces.AbstractFacesMojo.processIndexEntry(AbstractFacesMojo.java:297)
        at 
org.apache.myfaces.trinidadbuild.plugin.faces.AbstractFacesMojo.processIndex(AbstractFacesMojo.java:287)
        at 
org.apache.myfaces.trinidadbuild.plugin.faces.GenerateComponentsMojo.execute(GenerateComponentsMojo.java:59)
        at 
org.apache.myfaces.trinidadbuild.plugin.faces.GenerateComponentsMojoTest.testGenerate(GenerateComponentsMojoTest.java:89)
Caused by: org.xml.sax.SAXParseException: An 'include' failed, and no
'fallback' element was found.
        at 
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
        at 
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
        at org.apache.commons.digester.Digester.parse(Digester.java:1836)
        at 
org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacesConfigParser.merge(FacesConfigParser.java:60)
        ... 30 more

But the include still fails with no helpful information. Still would
not mind any help.

Thanks,
Andrew

On Wed, Jan 6, 2010 at 4:51 PM, Andrew Robinson
<[email protected]> wrote:
> Forgot to mention that it is looking for:
> /home/anrobins/development/maven-trinidad/branches/2.0.0-branch/maven-faces-plugin/TestInclude.xml
> but the correct path is:
> /home/anrobins/development/maven-trinidad/branches/2.0.0-branch/maven-faces-plugin/src/test/resources/META-INF/maven-faces-plugin/components/trinidad/faces/TestInclude.xml
>
> So I need to figure out how to set the base URL for the relative URL handling.
>
> -Andrew
>
>
> On Wed, Jan 6, 2010 at 4:21 PM, Andrew Robinson
> <[email protected]> wrote:
>> Hey all, I could really use some help. I have been unable so far to
>> get the maven-faces-plugin to resolve xml includes in the 2.0.1
>> version of the plugins. I removed xerces and the other XML
>> dependencies from the POM so that it would use the Java built-in XML.
>> Then I made it XInclude aware:
>>
>>  static protected Digester createEmptyDigester()
>>    throws ParserConfigurationException, SAXException
>>  {
>>    SAXParserFactory spf = SAXParserFactory.newInstance();
>>    spf.setNamespaceAware(true);
>>    // requires JAXP 1.3, in JavaSE 5.0
>>    spf.setXIncludeAware(true);
>>
>>
>> Here is the logging output:
>>
>> resolveEntity('null',
>> 'file:///home/anrobins/development/maven-trinidad/branches/2.0.0-branch/maven-faces-plugin/TestInclude.xml')
>> Jan 6, 2010 4:10:54 PM org.apache.commons.digester.Digester fatalError
>> SEVERE: Parse Fatal Error at line 37 column 90: An 'include' failed,
>> and no 'fallback' element was found.
>> org.xml.sax.SAXParseException: An 'include' failed, and no 'fallback'
>> element was found.
>>        at 
>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
>>        at 
>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
>>        at 
>> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
>>        at 
>> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
>>        at 
>> com.sun.org.apache.xerces.internal.xinclude.XIncludeHandler.reportError(XIncludeHandler.java:2320)
>>        at 
>> com.sun.org.apache.xerces.internal.xinclude.XIncludeHandler.reportFatalError(XIncludeHandler.java:2315)
>>        at 
>> com.sun.org.apache.xerces.internal.xinclude.XIncludeHandler.reportFatalError(XIncludeHandler.java:2311)
>>        at 
>> com.sun.org.apache.xerces.internal.xinclude.XIncludeHandler.endElement(XIncludeHandler.java:1001)
>>
>>
>> I tried to turn on validation
>>    spt.setValidating(true);
>>    spf.setFeature("http://apache.org/xml/features/validation/schema";, true);
>>
>> But then I ran into this:
>> SEVERE: Parse Error at line 26 column 73: cvc-elt.1: Cannot find the
>> declaration of element 'faces-config'.
>> org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration
>> of element 'faces-config'.
>>        at 
>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
>>        at 
>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
>>        at 
>> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
>>        at 
>> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
>>        at 
>> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1887)
>>        at 
>> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:685)
>>        at 
>> com.sun.org.apache.xerces.internal.xinclude.XIncludeHandler.startElement(XIncludeHandler.java:908)
>>        at 
>> com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)
>>
>>
>> In my project I have some of the fmd:* attributes being pulled in
>> through xi:include elements. Not using include would be a very hard
>> thing as we have many includes. Anyone know what I can do to get the
>> includes parsing correctly with the digester?
>>
>> Thank you!
>> -Andrew
>>
>

Reply via email to