XSLT에서 XML 노드 속성 작업
당신이 XML과 XSL을 사용하면 특성과 스타일에 XML 노드의 값을들을 플레이해야 할 때, 그때 당신은 시간을 가로질러 왔을 수도 있습니다. 그들은 이것에 대해 긴 숨이 찬 정보가있는 사이트의 부하이며, 내가 찾은 누구는 짧고 정확한없는 것 ... 이것은 XML / XSL 튜토리얼은 아니지만 컨닝 목록의 일종을 함께 넣어 내 시도 ...
우리가 일하는 것을 예제 XML은 다음과 같습니다 ...
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="food.xsl"?>
<food>
<fruits type="tropical">
<item name="mango" moreinfo="http://www.mango.com">Mango is the king of fruits</item>
<item name="banana" moreinfo="http://www.banana.com">Banana once a day , keeps the doctor away</item>
<item name="orange" moreinfo="http://www.orange.com">Orange is the color and rich in vitamin C</item>
<item name="Papaya" moreinfo="http://www.papaya.com">Papaya - Hot when raw, cold when ripe</item>
</fruits>
</food>
그럼 XSL을 사용하여 Google 위의 XML을 변환 시작하자
예제 1 : 선택된 속성에 값 표시하기
<xsl:value-of select="/food/fruits/item[@name='orange']" /><br />
to get more information about <a href="{/food/fruits/item[@name='orange']/@moreinfo}" target="new" ><xsl:value-of select="/food/fruits/item[@name='orange']/@name" /> </a>
HTML 결과 보일까
Orange is the color and rich in vitamin C,
to get more information about <a href="http://www.orange.com" target="new">
예제 2 :를 통해 반복 및 모든 XML 속성 이름과 값 표시
<xsl:for-each select="/food/fruits/item/@*">
attribute name : <xsl:value-of select="name()"/>,
attribute value : <xsl:value-of select="."/> <br />
</xsl:for-each>
HTML 결과 보일까
attribute name : name, attribute value : mango
attribute name : moreinfo, attribute value : http://www.mango.com
attribute name : name, attribute value : banana
attribute name : moreinfo, attribute value : http://www.banana.com
attribute name : name, attribute value : orange
attribute name : moreinfo, attribute value : http://www.orange.com
attribute name : name, attribute value : Papaya
attribute name : moreinfo, attribute value : http://www.papaya.com
여기에 위의 모든 파일 (245 다운로드) 다운로드
이 공간을보고, 나는 새로운 발견으로이 업데이 트에 반영하겠습니다 ...










































