2012-04-23 2 views
2

div 주위에 줄 바꿈 된 div가있는 HTML 페이지를 만들었습니다. 그러나 동일한 HTML을 사용하여 XSLT를 통해 일부 XML을 처리하면 한 div를 다른 div 위에 배치 할 수 있습니다. 왜 XML/XSLT에서이 작업을 수행하는지 생각할 수 있습니까?XSLT에서 DIV를 감쌌습니다.

#container { margin: 5px;padding: 5px;border: 0px solid black;} 
#floated { width: 227x;float: left;padding-right: 5px;padding-bottom: 10px;} 

예 XML :

<?xml version="1.0" encoding="utf-8"?> 
<xsl:stylesheet 
       version="1.0" 
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
       xmlns:xhtml="http://www.w3.org/1999/xhtml" 
> 


    <!-- Doctype - about:legacy-compat is XML equivalent of HTML5 doctype --> 
    <xsl:output method="html" indent="yes" 
       omit-xml-declaration="yes" 
       doctype-public="about:legacy-compat" 
    /> 

    <xsl:template name="Document" match="/"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>BPD</title> 
<link type="text/css" rel="stylesheet" href="big_picture_documentation_v3.css"/> 
</head> 
<body> 
<div id="container"> 
<div id="floated"> 
<p>WRAP AROUND ME!</p> 
</div> 
<xsl:apply-templates/> 
</div> 
</body> 
</html> 
</xsl:template> 

<xsl:template name="Title" match="title"> 
    <h1> 
    <xsl:apply-templates/> 
    </h1> 
</xsl:template> 
<xsl:template name="subheading" match="subheading"> 
    <h2> 
    <xsl:apply-templates/> 
    </h2> 
</xsl:template> 

</xsl:stylesheet> 

이 div의 포맷에 대한 CSS 아래에 볼 수 있습니다

<?xml version="1.0" encoding="utf-8"?> 
<?xml-stylesheet type="text/xsl" href="v3.xsl" ?> 
<document xmlns:xhtml="http://www.w3.org/1999/xhtml"> 
    <data id="HowToUse" type="example" status="Complete"> 
    <content> 
    <title>How To Navigate This Guide</title> 
    <subheading>Using This Documentation</subheading> 

    </content> 
    </data> 

</document> 
+0

변환중인 XML은 무엇입니까? – Treemonkey

+0

XML –

+0

예제로 완전히 업데이트되었습니다. 여기에있는 문제를 완전히 이해하지 못했습니다 ... xslt에 문제가있어서 빈 노드를 출력하려고 시도했을 수 있습니다. 이것이 문제인지 알아 보려면 header 태그 사이에 두 apply-templates 부분 뒤에 임의의 텍스트를 추가하십시오. – Treemonkey

답변

1
<div id="container"> 
<div id="floated"> 
<p>WRAP AROUND ME!</p> 
</div> 
<xsl:apply-templates/> 
</div> 

당신이 원하는 것을 나에게 보인다 is :

<div id="container"> 
<div id="floated"> 
    <p>WRAP AROUND ME!</p> 
    <xsl:apply-templates/> 
</div> 
</div> 
+0

응답 해 주셔서 감사합니다. 결국 나는 코드를 다시 작성했고 이전에 같은 줄에 있던 것과는 다른 별도의 줄에 닫는 div 태그를 배치하는 것만으로도 작동하는 것처럼 보였다. 매우 이상합니다. 내가 뭔가를 들여다 보지 않는 한 - 어쩌면 기질이 좋은 브라우저일까요? –

+0

@DanielShillcock :이 솔루션은'xsl : apply-templates'를 래퍼'div' 안에 넣습니다. 제공된 코드에서 * 외부 *입니다. –