###xmlhtml 파싱을 하다보면, 가끔씩 html코드들이 눈에 거슬릴 때가 많다. 특히 스트링 조작을 하다보면 끊어진 태그들이 그대로 웹상에서 나타나는 경우가 있는데, 보기에 좋지 않다. 위의 템플릿은 아예 태그자체를 낫띵으로 치환해 버려,그런 걱정이 필요없게 해 준다.
<xsl:template match="content[@name='body']" mode="content">
<xsl:variable name="regex"><![CDATA[<[^>]*>|</[^>]*>]]]]]><![CDATA[]></xsl:variable>
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:attribute name="name">clean-body</xsl:attribute>
<xsl:value-of select="viv:replace(., $regex, '', 'gi')" />
</xsl:copy>
</xsl:template>
'IT > etc' 카테고리의 다른 글
vi 에디터에서 특정 캐릭터를 가지고 개행을 할 경우 (0) | 2011.11.23 |
---|---|
티스토리에서 syntax hightlight하기 (0) | 2011.11.23 |
how to avoid autorun.inf file getting generated in a folder (0) | 2011.11.23 |
VB스크립트에서 첨부문서를 가지고 이메일 보내기 (0) | 2011.11.23 |
Apache(아파치)에서 크로스 사이트 스크립팅(cross site scripting: xss) 허용하기 (0) | 2011.11.23 |