xslt 변환을 사용하여 html 기반 템플릿을 만들려고합니다. 트랜스포머가 반환 한 문자열 결과는 완벽하게 훌륭합니다.하지만이를 표시하려고하면 브라우저가 해석하지 않습니다. 출력은 <html><body>...</body></html>
과 같습니다. 표시되는 소스를 볼 때 <html>...
어떻게 해결할 수 있습니까? 도와주세요. 미리 감사드립니다.XSLT 문제
XSLT 문제
답변
출력 방법을 올바르게 지정 했습니까? HTML로 설정해야합니다 :
<xsl:output method="html" encoding="UTF-8" />
예 출력 방법 'html'을 사용했습니다. 서버 콘솔에서 문자열을 인쇄 할 때 제대로 HTML 태그를 인쇄하지만 브라우저에서는 해석되지 않습니다. – sindhu
@sindhu : 스타일 시트와 코드를 호출하고 출력을 저장하는 데 사용할 수있는 코드를 표시 할 수 있습니까? –
<xsl:output value="html"/> <xsl:template match="mail[@type='pinReset']">
<html><body> <xsl:variable name="userService" select="java:new()"/> <i><u>Message body </u><xsl:value-of select="mailMessage/mail/body/prefix"/></i> <a><xsl:attribute name="href"> <xsl:value-of select="java:getResetPinUrl($userService)"/></xsl:attribute> reset pin </a> <i><xsl:value-of select="mailMessage/body/suffix"/></i><br/>
</body> </html> </xsl:template> </xsl:stylesheet>
이 내 XSL입니다.
public String getXformedString(int type){ String xFormedString = ""; String xsltFile = "D:\\SitesContent\\sitescontent_war\\JavaSource\\com\\tgt\\mobile\\gc\\controller\\email.xsl"; String xmlFile="D:\\SitesContent\\sitescontent_war\\JavaSource\\com\\tgt\\mobile\\gc\\controller\\emailBody.xml"; StringWriter stWr = new StringWriter(); File xsltfile = new File(xsltFile); File xmlfile = new File(xmlFile); Source xmlSource = new StreamSource(xmlfile); Source xsltSource = new StreamSource(xsltfile); Result result = new StreamResult(stWr); TransformerFactory transFact = TransformerFactory.newInstance(); try { Transformer transformer= transFact.newTransformer(xsltSource); transformer.setParameter("type",new Integer(type)); transformer.transform(xmlSource, result); xFormedString = stWr.toString(); System.out.println("Str->"+xFormedString); } catch (TransformerConfigurationException e) { // TODO Auto-generated catch block
e.printStackTrace(); } catch (TransformerException e) { // TODO Auto-generated catch block e.printStackTrace(); } return xFormedString; }
이
는 XML 및 XSLT에서 형성 문자열을 얻을 수있는 코드입니다.- 1. XSLT 문제 문제
- 2. XSLT 출력의 앰퍼샌드 문제
- 3. XSLT 일치 문제
- 4. SharePoint XSLT 문제 -
- 5. XSLT 템플릿 일치 문제
- 6. XSLT 메뉴 생성 문제
- 7. XSLT Firefox 문제
- 8. XSLT 캐시 문제
- 9. xslt 드롭 다운 문제
- 10. xslt 배열 문제
- 11. XSLT 그룹화 재귀 문제
- 12. XSLT 및 네임 스페이스 문제
- 13. XSLT 그룹화 계속 - xPath 문제?
- 14. XSLT - XSLT
- 15. XSLT
- 16. XSLT
- 17. XSLT
- 18. XSLT
- 19. XSLT 스타일 시트 상대 경로 문제 Windows에서
- 20. 사용하여 XSLT
- 21. 이 XSLT 들어 XSLT 처리
- 22. xslt 정렬
- 23. 는 XSLT
- 24. Sandcastle xslt
- 25. XSLT 추상화
- 26. 는 XSLT
- 27. XSLT foreach
- 28. XSLT 가변
- 29. XML을 - XSLT
- 30. XSLT HTML
스타일 시트를 보여줄 수 있습니까? –