Author: scabanovich
Date: 2007-09-18 08:25:10 -0400 (Tue, 18 Sep 2007)
New Revision: 3684
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/FacesConfigLoader.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFEntityRecognizer.java
Log:
JBIDE-898
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/FacesConfigLoader.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/FacesConfigLoader.java 2007-09-18
12:24:38 UTC (rev 3683)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/FacesConfigLoader.java 2007-09-18
12:25:10 UTC (rev 3684)
@@ -38,10 +38,8 @@
String body = XModelObjectLoaderUtil.getTempBody(object);
int resolution =
EntityXMLRegistration.getInstance().resolve(object.getModelEntity());
+ if(EntityXMLRegistration.isSystemId(body)) resolution =
EntityXMLRegistration.UNRESOLVED;
String[] errors =
-// (entity.equals(ENT_FACESCONFIG_12))
-// ? new SAXValidator().getXMLErrors(new StringReader(body))
-// : XMLUtil.getXMLErrors(new StringReader(body));
XMLUtil.getXMLErrors(new StringReader(body), resolution == EntityXMLRegistration.DTD,
resolution == EntityXMLRegistration.SCHEMA);
boolean hasErrors = (errors != null && errors.length > 0);
if(hasErrors) {
@@ -73,6 +71,9 @@
if(n instanceof DocumentType) {
DocumentType dt = (DocumentType)n;
object.setAttributeValue("systemId", dt.getSystemId());
+ if(dt.getPublicId() == null) {
+ object.setAttributeValue("publicId", "null");
+ }
}
}
}
@@ -164,6 +165,7 @@
String entity = object.getModelEntity().getName();
String systemId = object.getAttributeValue("systemId");
String publicId = object.getAttributeValue("publicId");
+ if("null".equals(publicId)) publicId = null;
if(systemId != null) {
int version = entity.equals(ENT_FACESCONFIG_11) ? 11 : 10;
@@ -171,7 +173,7 @@
if(publicId != null && publicId.length() == 0) publicId = (version ==
10) ? DOC_PUBLICID : DOC_PUBLICID_11;
}
- Element element = (systemId == null || publicId == null)
+ Element element = (systemId == null && publicId == null)
? XMLUtil.createDocumentElement(object.getModelEntity().getXMLSubPath())
: XMLUtil.createDocumentElement(object.getModelEntity().getXMLSubPath(),
DOC_QUALIFIEDNAME, publicId, systemId, null);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFEntityRecognizer.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFEntityRecognizer.java 2007-09-18
12:24:38 UTC (rev 3683)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFEntityRecognizer.java 2007-09-18
12:25:10 UTC (rev 3684)
@@ -30,8 +30,16 @@
public String getEntityName(String ext, String body) {
if(body == null) return null;
- if(body.indexOf(DOC_PUBLICID) > 0) return ENT_FACESCONFIG;
- if(body.indexOf(DOC_PUBLICID_11) > 0) return ENT_FACESCONFIG_11;
+ int i = body.indexOf("<!DOCTYPE");
+ if(i >= 0) {
+ int j = body.indexOf(">", i);
+ if(j < 0) return null;
+ String dt = body.substring(i, j);
+ if(dt.indexOf("faces-config") < 0) return null;
+ if(dt.indexOf(DOC_PUBLICID) > 0) return ENT_FACESCONFIG;
+ if(dt.indexOf(DOC_PUBLICID_11) > 0) return ENT_FACESCONFIG_11;
+ if(dt.indexOf("SYSTEM") > 0 &&
dt.indexOf("web-facesconfig_1_1.dtd") > 0) return ENT_FACESCONFIG_11;
+ }
if(is12(body)) return ENT_FACESCONFIG_12;
return null;
}
Show replies by date