You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 18:05:39 UTC
[myfaces-trinidad-maven] 03/10: TRINIDAD-919
This is an automated email from the ASF dual-hosted git repository.
deki pushed a commit to branch 1.2.6.1-branch
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad-maven.git
commit 6d1ea90149b53ae3a51e530fe1b5ffc4a48269dd
Author: Matthias Wessendorf <ma...@apache.org>
AuthorDate: Wed Jan 23 21:33:49 2008 +0000
TRINIDAD-919
---
.../plugin/jdeveloper/TldContentHandler.java | 70 ++++++++++++++++++----
1 file changed, 58 insertions(+), 12 deletions(-)
diff --git a/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java b/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java
index fa327bb..afa1a71 100644
--- a/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java
+++ b/maven-jdev-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/TldContentHandler.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,9 +18,11 @@
*/
package org.apache.myfaces.trinidadbuild.plugin.jdeveloper;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -30,6 +32,8 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public class TldContentHandler
@@ -40,9 +44,9 @@ public class TldContentHandler
public TldContentHandler()
{
}
-
+
/**
- * Parse the .tld file to get the information
+ * Parse the .tld file to get the information
* needed for the .jpr
*/
public void parseTld(File file)
@@ -53,9 +57,15 @@ public class TldContentHandler
// Create a builder factory
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
-
+
// Create the Builder and parse the file
- Document document = factory.newDocumentBuilder().parse(file);
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+
+ // Set Entity Resolver to resolve external entities, i.e.
+ // the "http://...." in the <!DOCTYPE tag
+ EntityResolver entityResolver = new PluginEntityResolver();
+ docBuilder.setEntityResolver(entityResolver);
+ Document document = docBuilder.parse(file);
_processTldNodes(document);
}
@@ -118,13 +128,13 @@ public class TldContentHandler
/**
* Find all the TLD nodes we want, get each node's value
* and set the value on the proper class property.
- *
+ *
* @param document - DOM Document from the TLD file
- */
+ */
private void _processTldNodes(Document document)
{
Node node = null;
-
+
// Get the Nodes first node. We can be specific here
// because we know we want the first node.
NodeList nodeList = document.getElementsByTagName(_TLIB_VERSION);
@@ -168,20 +178,56 @@ public class TldContentHandler
setURI(node.getFirstChild().getNodeValue());
}
}
-
+
//========================================================================
// Private variables
//========================================================================
-
+
private String _version = null; // tlib-version
private String _name = null; // display-name
private String _prefix = null; // short-name
private String _jspVersion = null; // jsp-version
private String _uri = null; // uri
-
+
private final static String _TLIB_VERSION = "tlib-version"; //version NOTRANS
private final static String _DISPLAY_NAME = "display-name"; //name NOTRANS
private final static String _SHORT_NAME = "short-name"; //prefix NOTRANS
private final static String _JSP_VERSION = "jsp-version"; //NOTRANS
private final static String _URI = "uri";
+
+
+ /**
+ * Gary Kind 01/22/2008. This class is used solely to get around a
+ * java.net.NoRouteToHostException that occurs in the tag libs
+ * <!DOCTYPE... tag, which is:
+ *
+ * <!DOCTYPE taglib
+ * PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
+ * "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
+ *
+ * The http URL causes this exception for some unknown reason. I have
+ * searched high and low on the web for a real solution and finally found
+ * this workaround at
+ * http://forum.java.sun.com/thread.jspa?threadID=284209&forumID=34
+ * Apparently a LOT of developers are seeing similar problems and they too
+ * are not able to find a solution. This workaround works perfectly and all
+ * is well.
+ */
+ private class PluginEntityResolver
+ implements EntityResolver
+ {
+ public InputSource resolveEntity(String publicId, String systemId)
+ {
+ if ("-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN".equals(publicId))
+ {
+ String xmlStr = "<?xml version='1.0' encoding='UTF-8'?>";
+ byte[] buf = xmlStr.getBytes();
+ ByteArrayInputStream bais = new ByteArrayInputStream(buf);
+ return new InputSource(bais);
+ }
+ else
+ return null;
+ }
+ }
+
} // endclass TldContentHandler
--
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.