Re: Taglib Import: xml Validation Errors with

Michael Wohlfart <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Thanks guys for the fast replies,

setting the <!DOCTYPE > value in web.xml helped to solve the
validation error for web.xml at least.

I am a bit spoiled by the spring injector pattern and thought
there might be an easy way to inject my own TaglLibFactory that
I overlooked so far, but compiling my own version is a good
option too.


Thanks for the nice work

Michael



Attila Szegedi wrote:
> Sure, try turning validation off and see whether it fixes your  
> problem. It is really easy to rebuild freemarker.jar, you just need to  
> issue "ant jar" -- build.xml will download all required dependencies  
> from the Internet automatically.
> 
> It is indeed a curious problem that you're getting these errors. I  
> guess the JAXP "setValidation(true)" would mandate DTD validation, and  
> it doesn't consider XML Schema validation? Just a guess...
> 
> Attila.
> 
> On 2007.12.07., at 11:04, Michael Wohlfart wrote:
> 
>> Hi there,
>>
>> I just started using FreeMarker to replace some of my JSP-Views
>> in my Spring Application and I am pretty impressed so far.
>>
>> The only ugly thing I could find is an validation error when
>> using Taglibs. My Environment ist Spring 2.5, Tomcat 6.0.14,
>> FreeMarker 2.3.11. JRE6
>>
>> My Import of the taglib in my Template looks like this:
>> <#assign c=JspTaglibs["http://java.sun.com/jstl/core_rt"] />
>>
>> I guess it is not the standard way, most examples I found
>> use the "*.tld" path here, but this seems to work.
>>
>> At view creation time I get the following validation Errors:
>>
>> Warning: validation was turned on but an org.xml.sax.ErrorHandler  
>> was not
>> set, which is probably not what is desired.  Parser will use a default
>> ErrorHandler to print the first 10 errors.  Please call
>> the 'setErrorHandler' method to fix this.
>> Error: URI=jndi:/localhost/cms/WEB-INF/web.xml Line=6: Document root  
>> element "web-app", must match DOCTYPE root "null".
>> Error: URI=jndi:/localhost/cms/WEB-INF/web.xml Line=6: Document is  
>> invalid: no grammar found.
>> Warning: validation was turned on but an org.xml.sax.ErrorHandler  
>> was not
>> set, which is probably not what is desired.  Parser will use a default
>> ErrorHandler to print the first 10 errors.  Please call
>> the 'setErrorHandler' method to fix this.
>> Error: URI=jar:file:/E:/cfs_web/.metadata/.plugins/ 
>> org.eclipse.wst.server.core/tmp1/wtpwebapps/cms/WEB-INF/lib/ 
>> standard.jar!META-INF/c.tld Line=6: Document root element "taglib",  
>> must match DOCTYPE root "null".
>> Error: URI=jar:file:/E:/cfs_web/.metadata/.plugins/ 
>> org.eclipse.wst.server.core/tmp1/wtpwebapps/cms/WEB-INF/lib/ 
>> standard.jar!META-INF/c.tld Line=6: Document is invalid: no grammar  
>> found.
>> Warning: validation was turned on but an org.xml.sax.ErrorHandler  
>> was not
>> set, which is probably not what is desired.  Parser will use a default
>> ErrorHandler to print the first 10 errors.  Please call
>> the 'setErrorHandler' method to fix this.
>> [...]
>>
>>
>> my web.xml starts like this and I am not sure what the validation
>> whining is about:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <web-app id="blabla-System"
>>         version="2.4"
>>         xmlns="http://java.sun.com/xml/ns/j2ee"
>>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd 
>> ">
>>
>>    <display-name>blabla System</display-name>
>> [...]
>>
>>
>> So based on the opinion that i am smarter than the xml-validator,  
>> and that the
>> tlds in the jar file are correct I want to turn off xml-validation  
>> (somewhat
>> risky i know). Is there a way to use my own TaglibFactory, the  
>> default implementation
>> turns on the validation somewhere around line 370 as far as i  
>> understand the code,
>> setting the validation to off in this method should do the job ?
>>
>>    private static void parseXml(InputStream in, String url,  
>> DefaultHandler handler)
>>    throws
>>        ParserConfigurationException, IOException, SAXException
>>    {
>>        InputSource is = new InputSource();
>>        is.setByteStream(in);
>>        is.setSystemId(url);
>>        SAXParserFactory factory = SAXParserFactory.newInstance();
>>        factory.setNamespaceAware(false);
>>        factory.setValidating(true);
>>        XMLReader reader = factory.newSAXParser().getXMLReader();
>>        reader.setEntityResolver(new LocalTaglibDtds());
>>        reader.setContentHandler(handler);
>>        reader.parse(is);
>>    }
>>
>>
>> I am open for any other suggestions to get rid of the ugly  
>> validation errors.
>>
>>
>> thanks & best regards
>> Michael
> 
> 
> 
> 
> -------------------------------------------------------------------------
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
> 



-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.