के साथ एक एकल विशेषता परिवर्तन क्या सरलतम XSLT आप सोच सकते हैं मूल्य पहले से ही विशेषता true
से false
को बदलने के लिए, इस मामले में, /configuration/system.web/compilation/@debug
है?
XSLT
उत्तर
यह परिवर्तन:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="system.web/compilation[1]/@debug">
<xsl:attribute name="debug">false</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
जब इस XML दस्तावेज़ पर लागू: को संशोधित करता है पहले compilation
बच्चे की debug
विशेषता:
<configuration>
<system.web>
<compilation debug="true" defaultLanguage="C#">
<!-- this is a comment -->
</compilation>
<compilation debug="true" defaultLanguage="C#">
<!-- this is another comment -->
</compilation>
</system.web>
</configuration>
चाहता था, सही परिणाम का उत्पादन किसी भी system.web
तत्व (लेकिन हम जानते हैं कि चालू है एक कॉन्फ़िगरेशन फ़ाइल में एक system.web
तत्व ly।
<configuration>
<system.web>
<compilation debug="false" defaultLanguage="C#">
<!-- this is a comment -->
</compilation>
<compilation debug="true" defaultLanguage="C#">
<!-- this is another comment -->
</compilation>
</system.web>
</configuration>
हम देखते हैं के रूप में, केवल पहले debug
गुण, false
को modifird के रूप में आवश्यक है।
इसे एक्सएसएलटी के लिए पहचान पैटर्न बदलने के लिए कहा जाता है, और @Dimitre Novatchev ने बताया, यह बेहद शक्तिशाली है। – lavinio
यह एक शर्म की बात है कि 'xsl: विशेषता' तत्व को विशेषता के नाम का उल्लेख करना होगा, जब इसे पहले से ही XPath में दिया गया है जो 'xsl: template' मिलान संलग्न है। क्या यह कहने का कोई तरीका है "इस विशेषता को सेट करें, जिसे भी कहा जाता है"? –
@ टॉम एंडरसन: कोई एवीटी नोटेशन का उपयोग कर सकता है: '
<xsl:attribute name="debug">false</xsl:attribute>
<compilation>
के अंदर? या क्या मैं इस सवाल को गलत समझ रहा हूं?
- 1. xslt
- 2. XSLT
- 3. xslt
- 4. xslt
- 5. xslt
- 6. XSLT
- 7. XSLT
- 8. xslt
- 9. xslt
- 10. XSLT
- 11. xslt
- 12. xslt
- 13. xslt
- 14. XSLT
- 15. xslt
- 16. xslt
- 17. XSLT
- 18. xslt 1.0
- 19. कैसे xslt
- 20. xslt: तत्व
- 21. सम्मिलित XSLT
- 22. कैसे XSLT
- 23. मैं xslt
- 24. मैं XSLT
- 25. XSLT: लूप एक समय
- 26. मेमोरी कुशल XSLT प्रोसेसर
- 27. xslt और xml त्रुटि
- 28. XSLT समारोह दस्तावेज़() वाइल्डकार्ड
- 29. गतिशील रूप XSLT
- 30. xslt:-स्ट्रिंग-से पहले
अच्छा प्रश्न (+1)। एक संक्षिप्त, सरल और सही समाधान के लिए मेरा जवाब देखें। वर्तमान में लुसेरो का जवाब काफी गलत है - मेरे जवाब पर मेरी टिप्पणी देखें। –