Hi, I had the following problem with the <x:parse/> standard tag: when importing an XML file like this:
<c:import url="http://hostname/path/to/file.xml" var="xml"/> <x:parse source="$xml" var="doc" /> Where the (externally generated) XML file contains a reference to a DTD (and hence the file should be validated). The parse statement should be able to know where to find the DTD, but it couldn't as the DTD was relative to the XML file being imported. Below is a patch that will allow a user to do the following: <x:parse source="http://hostname/path/to/file.xml" var="doc" /> It will read the file from the URL and perform any validation as necessary. So, no more <c:import/> necessary. Of course, this might not be entirely the right way to use the source attribute, but I saw no other way to do it. Please review. Here's the patch for org.apache.taglibs.standard.tag.xml.ParseSupport.java: *** ParseSupport.java.orig Wed Jan 2 16:33:33 2002 --- ParseSupport.java Wed Jan 2 17:17:40 2002 *************** *** 56,61 **** --- 56,63 ---- package org.apache.taglibs.standard.tag.common.xml; import java.io.*; + import java.net.URL; + import java.net.MalformedURLException; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import javax.xml.parsers.*; *************** *** 198,203 **** --- 200,215 ---- /** Parses the given String into a Document. */ private Document parseString(String s) throws SAXException, IOException { + /* Is the source attribute a URL? */ + try { + URL url = new URL(s); + /* Yes, parse the URL */ + return db.parse(new InputSource(s)); + } catch (MalformedURLException ex) { + // Ignore + } + + /* No, it's XML */ StringReader r = new StringReader(s); return parseReader(r); } Cheers, Jeroen -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
