XSL in Hindi
RGPV University / DIPLOMA_CSE / Web Technology
XSL Explained in Hindi - XSLT Structure, Components, and Applications
XSL in Hindi
Introduction to XSL
XSL का पूरा नाम Extensible Stylesheet Language है। इसका उपयोग XML डेटा को presentable format में दिखाने के लिए किया जाता है, जैसे कि HTML या PDF। XSL हमें XML डॉक्युमेंट को transform और style करने की सुविधा देता है। XSL मुख्यतः तीन भागों में बांटा जाता है:
- XSLT (XSL Transformations) – XML डेटा को किसी और format में transform करने के लिए।
- XPath – XML डॉक्युमेंट में specific elements को select करने के लिए।
- XSL-FO (Formatting Objects) – Output को format करने के लिए, जैसे कि PDF फॉर्मेट।
Why use XSL?
- यह हमें raw XML डेटा को human-readable format में बदलने में मदद करता है।
- Web applications में XML डेटा को HTML में बदलने के लिए उपयोगी होता है।
- Data presentation को user-friendly बनाने में सहायक है।
Components of XSL in Hindi
Main Components of XSL
XSL के मुख्य components निम्नलिखित हैं:
- XSLT – Transformation के लिए प्रयोग किया जाता है।
- XPath – XML डॉक्युमेंट में navigation के लिए।
- XSL-FO – Formatting Object जिससे हम output को format करते हैं, जैसे कि प्रिंट करने के लिए।
Example of XSLT Code
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Student List</h2>
<xsl:for-each select="students/student">
<p><xsl:value-of select="name"/></p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSLT Syntax and Structure in Hindi
Basic Structure of XSLT
XSLT डॉक्युमेंट की structure XML based होती है। इसकी मुख्य structure कुछ इस प्रकार होती है:
- <xsl:stylesheet> – यह root element होता है।
- <xsl:template> – यह बताता है कि किस XML element पर कौन सा transformation rule apply होगा।
- <xsl:value-of> – XML डेटा को select और display करने के लिए।
- <xsl:for-each> – XML elements पर loop चलाने के लिए।
XPath in XSLT
XPath का प्रयोग XML nodes को navigate करने के लिए होता है। उदाहरण:
/students/student
– root से लेकर प्रत्येक student node को select करता है।name
– current node का name element select करता है।
Advantages of Using XSL in Hindi
Key Benefits of XSL
- XML डेटा को अलग-अलग format में convert करना आसान बनाता है।
- Presentation layer को data layer से अलग करता है।
- Reusable और modular design को promote करता है।
- XPath के माध्यम से powerful data access और navigation प्रदान करता है।
Real-world Applications of XSL in Hindi
Where XSL is Used?
- Web development – Dynamic content rendering के लिए XML को HTML में बदलने में।
- Enterprise software – Report generation और data transformation के लिए।
- Publishing industry – XML से PDF reports या eBooks generate करने के लिए।
- Data migration tools – Legacy डेटा को modern systems में convert करने में।
Example Use-case: XML to HTML Table
<xsl:template match="/">
<html>
<body>
<table border="1">
<xsl:for-each select="students/student">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="roll"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>