문제

I've got an arbitrary XHTML document which are usually not well formed, since websites can be made like that and browser will show it. How can I support XSLT translation for not well formed XHTML code? Is there a way that it can avoid those parts which are not well formed?

I have this code in Java, but as I've said it's not supporting not well formed XHTML:

try {
            TransformerFactory tFactory=TransformerFactory.newInstance();

            Source xslDoc=new StreamSource("path1");
            Source xmlDoc=new StreamSource("path2");

            String outputFileName="path3";

            OutputStream htmlFile=new FileOutputStream(outputFileName);
            Transformer trasform=tFactory.newTransformer(xslDoc);
            trasform.transform(xmlDoc, new StreamResult(htmlFile));
        } 
catch (Exception e) {...}
도움이 되었습니까?

해결책

You can use JSoup library to parse and fix your HTML and then use XSLT.

다른 팁

You can try to use an HTML parser like http://about.validator.nu/htmlparser/ or like TagSoup.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top