2014-04-25 1 views
0

내 xsl을 가진 변환을 내 xml 파일에 적용하려고합니다.변형 후 xmlt 태그를 복제하십시오.

이것은 내 XML입니다.

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
    <xsl:template match="/"> 
    <html> 
     <body> 
     <xsl:for-each select="messages/message"> 
      <from> 
       <xsl:value-of select="from"/> 
      </from> 
      <to> 
       <xsl:value-of select="to"/> 
      </to> 
      <text> 
       <xsl:value-of select="text"/> 
       <strong> 
       <xsl:value-of select="text/strong"/> 
       </strong> 
      </text> 
     </xsl:for-each> 
     </body>  
    </html> 
    </xsl:template> 
</xsl:stylesheet> 

모두가 <text><strong></strong></text>하지 않는 한, 완벽 :

<?xml version="1.0" encoding="UTF-8"?> 
<messages> 
    <message> 
    <from>Pepe ([email protected])</from> 
    <to>Juan ([email protected])</to> 
    <datetime>28/02/2011 17:48:23,61</datetime> 
    <text>¿Hello, Johnn, what's up?</text> 
    </message> 
    <message> 
    <from>Juan ([email protected])</from> 
    <to>Pepe ([email protected])</to> 
    <datetime>28/02/2011 17:54:20,87</datetime> 
    <text>Here, learning <strong>XML</strong></text> 
    </message> 
</messages> 

는 그리고 이것은 내 XSL 코드입니다. 문제는 내가 잘못이 결과를 얻는 XML 변환 할 때 제공 : 어떤 이유로

<text>Here, learning XML<strong>XML</strong></texto> 

을 내가 <strong> 태그에서 복제 된 XML을 얻고 실수 어디 모르겠어요.

감사합니다. 더 나은

답변

1

그리고는이었을 것입니다 :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
<xsl:template match="/"> 
    <html> 
     <body> 
      <xsl:for-each select="messages/message"> 
       <xsl:copy-of select="from"/> 
       <xsl:copy-of select="to"/> 
       <xsl:copy-of select="text"/> 
      </xsl:for-each> 
     </body>  
    </html> 
</xsl:template> 

+0

저에게 효과적이었던 저의 실수는 텍스트 내부에 딱딱함을 복사해야 할 때의 가치였습니다. 감사 – DevStarlight

0

XSL : 가치의 모든 텍스트 노드가 지정된 노드에서 즉, 당신에게 주어진 노드의 문자열 값을 제공합니다. 이것이 "XML"텍스트가 복제 된 것을 볼 수있는 이유입니다.이 텍스트는 <text><strong>의 문자열 값의 일부입니다.

관련 문제