<bookmarks>
<bookmark name='1. Foo bar baz' href='#1'>
<bookmark name='1.1 Baz quux' href='#1.2'>
</bookmark>
</bookmark>
<bookmark name='2. Foo bar baz' href='#2'>
<bookmark name='2.1 Baz quux' href='#2.2'>
</bookmark>
</bookmark>
</bookmarks>
는 HEAD 섹션에 투입해야
, 나는 그 일을했지만 SAXParser를 못해 말을 더 이상 파일을 읽을 :
line 11 column 14 - Error: <bookmarks> is not recognized!
line 11 column 25 - Error: <bookmark> is not recognized!
내가 로컬 엔티티 리 조르바를 설정하고도에 북마크를 추가 한이 DTD,
<!--flying saucer bookmarks -->
<!ELEMENT bookmarks (#PCDATA)>
<!ATTLIST bookmarks %attrs;>
<!ELEMENT bookmark (#PCDATA)>
<!ATTLIST bookmark %attrs;>
하지만 구문 분석이되지 않습니다. 아이디어가 없습니다. 제발 도와주세요.
내가 구문 분석하려면 다음 코드를 사용하고
편집 :
class LocalEntityResolver implements EntityResolver {
private static final Logger LOG = ESAPI.getLogger(LocalEntityResolver.class);
private static final Map<String, String> DTDS;
static {
DTDS = new HashMap<String, String>();
DTDS.put("-//W3C//DTD XHTML 1.0 Strict//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
DTDS.put("-//W3C//DTD XHTML 1.0 Transitional//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd");
DTDS.put("-//W3C//ENTITIES Latin 1 for XHTML//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent");
DTDS.put("-//W3C//ENTITIES Symbols for XHTML//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent");
DTDS.put("-//W3C//ENTITIES Special for XHTML//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent");
}
@Override
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
InputSource input_source = null;
if (publicId != null && DTDS.containsKey(publicId)) {
LOG.debug(Logger.EVENT_SUCCESS, "Looking for local copy of [" + publicId + "]");
final String dtd_system_id = DTDS.get(publicId);
final String file_name = dtd_system_id.substring(
dtd_system_id.lastIndexOf('/') + 1, dtd_system_id.length());
InputStream input_stream = FileUtil.readStreamFromClasspath(
file_name, "my/class/path",
getClass().getClassLoader());
if (input_stream != null) {
LOG.debug(Logger.EVENT_SUCCESS, "Found local file [" + file_name + "]!");
input_source = new InputSource(input_stream);
}
}
return input_source;
}
}
내 D :
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dbf.newDocumentBuilder();
builder.setEntityResolver(new LocalEntityResolver());
document = builder.parse(is);
편집 여기
은 LocalEntityResolver입니다 문서 빌더 팩토리 구현은 다음과 같습니다. com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
null입니다 있는지 확인하기 위해 검사가 포함되어 있습니다. 나 또는 다른 누구도 문제를 재현 할 수 있습니까? – mzjn
기본적으로 W3C Transitional DTD를 사용하여 특정 알 수없는 요소가있는 유효한 XHTML을 DOM 트리로 구문 분석하려고합니다. 재현하려면 유효한 XHTML을 사용하고 책갈피 html을 추가하고 dom 트리로 구문 분석을 시도하십시오 – epoch
'LocalEntityResolver'란 무엇입니까? 그거 어디서 났어? Xerces 소스에서'{element}가 인식되지 않습니다! '라는 메시지를 찾을 수 없습니다. –