עבודה עם תכונות ה-XML צומת XSLT
אם אתה משתמש ב-XML ו-XSL, אז אתה יכול לבוא על פני זמן, כאשר אתה צריך לשחק עם התכונות והערכים של צמתים XML ב-XSL לך. הם המון אתרים עם מידע מייגעים על זה, אבל לא מצאתי היו קצרות ומדויקות ... זה לא TUTORIAL 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>
כך מאפשר להתחיל להפוך XML מעל שלנו באמצעות XSL
דוגמה 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
להוריד את כל הקבצים הנ"ל כאן (243 הורדות)
לראות את החלל הזה, אני אמשיך לעדכן את זה עם הממצאים החדשים ...










































