Snusmumrikenx
Recruit
Hello!
I'm a newbie modder making use of XSLT to modify some files, more specifically the description of some towns and villages. The following lines are an example of how I successfully replaced a description of a village.
The problem I have is when a town, village or castle is lacking a text description attribute in the first place. Then those lines don't work. I know you can add such attributes by using a normal xml file, but I'd much rather prefer if I could do it in the xslt file. Since I'm a newbie modder with no programing background, I rely on looking at how other mods make stuff work, but in this case I've not found any examples. Could anyone help me formulate what those lines should look like for this to work? Would be much appreciated!
I'm a newbie modder making use of XSLT to modify some files, more specifically the description of some towns and villages. The following lines are an example of how I successfully replaced a description of a village.
XML:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match='Settlement[@id="castle_village_S3_1"]/@text'>
<xsl:attribute name='text'>NEW DESCRIPTION</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
The problem I have is when a town, village or castle is lacking a text description attribute in the first place. Then those lines don't work. I know you can add such attributes by using a normal xml file, but I'd much rather prefer if I could do it in the xslt file. Since I'm a newbie modder with no programing background, I rely on looking at how other mods make stuff work, but in this case I've not found any examples. Could anyone help me formulate what those lines should look like for this to work? Would be much appreciated!