Can I Use Variables in Xml Files?
Is It Possible to Define Variables in an Xml File? for Example: Variable = 'Chief_Name' French Toast $4.50 600 Variable Homestyle Breakfast $6.95 950 Variable...
Is it possible to define variables in an XML file?
For example:
VARIABLE = 'CHIEF_NAME'
<foods>
<food>
<name>French Toast</name>
<price>$4.50</price>
<calories>600</calories>
<chief>VARIABLE</chief>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<calories>950</calories>
<chief>VARIABLE</chief>
</food>
</foods>
2 Answers
You can declare an entity reference for chief and reference it as &chief;:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE foods [
<!ENTITY chief "CHIEF_NAME!">
<!-- .... -->
]>
<foods>
<food>
<name>French Toast</name>
<price>$4.50</price>
<calories>600</calories>
<chief>&chief;</chief>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<calories>950</calories>
<chief>&chief;</chief>
</food>
</foods>
Thats what XSLT is for.
Something to get you started:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="yourVar" select="'CHIEF_NAME'">
</xsl:variable>
<xsl:template match="/">
<food>
<name>French Toast</name>
<price>$4.50</price>
<calories>600</calories>
<chief><xsl:copy-of select="$yourVar" /></chief>
</food>
</xsl:template>
</xsl:stylesheet>
This syntax is not exactly correct, but I think generally this is the direction you should seek