Hello I have xml input
<?xml version="1.0" encoding="UTF-8"?>
<?Xpress productline="smartdoc"?>
<section xmlns="http://w3.com/content/3.0" id="_f6ded403-f94f-4123-a2f2-5ae75e482d88" type="document">
<title>UI/UX Elements</title>
<section id="_192a87c8-6754-472e-9ab3-4d760c071004" type="section">
<body>
<region id="_6cf44f92-1de1-4603-a4a7-1ac2e2020508" type="callout">
<p>
<t><b>Key Point</b>: There are four basic types of curation that L&D departments should leverage: traditional, self, machine, and social.</t>
</p>
</region>
<p>
<t> </t>
</p>
<region id="_b0ec8f84-65ea-4590-a1da-ee6f79a2af67" type="callout">
<p>
<t><b>ANALYSIS</b>: There are four basic types of curation that L&D departments should leverage: traditional, self, machine, and social.</t>
</p>
</region>
<p>
<t> </t>
</p>
<p>
<t> </t>
</p>
<region id="_72ced280-a2fe-499b-af54-c32c1414f7e1" type="callout">
<p>
<t><b>PREDICTION</b>: There are four basic types of curation that L&D departments should leverage: traditional, self, machine, and social. There are four basic types of curation that L&D departments should leverage: traditional, self, machine, and social.</t>
</p>
</region>
</body>
</section>
</section>
And the following XSLT
<xsl:template match="region">
<xsl:element name="div">
<xsl:attribute name="id" select="@id"/>
<xsl:choose>
<xsl:when test="@type = 'box' and (//region/region/region[@type='box'])">
<xsl:attribute name="class" select="'key-takeaways no-accordian'"/>
<xsl:apply-templates/>
</xsl:when>
<xsl:when test="(./p/t/b[starts-with(lower-case(.), 'prediction')]">
<xsl:attribute name="class" select="'prediction'"/>
<xsl:apply-templates/>
</xsl:when>
<!-- <xsl:when test="(//region[@type='callout'])/p/t/b[starts-with(lower-case(.), 'prediction')]">
<xsl:attribute name="class" select="'prediction'"/>
<xsl:apply-templates/>
</xsl:when> -->
<xsl:when test="(//region[@type='callout'])/p/t/b[starts-with(lower-case(.), 'key')]">
<xsl:attribute name="class" select="'key-point'"/>
<xsl:apply-templates/>
</xsl:when>
<xsl:when test="@type = 'box'">
<xsl:attribute name="class" select="'box-region'"/>
<xsl:apply-templates/>
</xsl:when>
<xsl:when test="@type = 'callout'">
<xsl:attribute name="class" select="'callout-region row'"/>
<xsl:attribute name="style" select="'width : 100%'"/>
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class" select="'default-region'"/>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
The structure of the document is going to always be the same and I have to apply specific class name depending on the text inside the /region/p/t/b node i.e if that value is Key Point then the class name will be key-point if the value is Analysis the class name is analysis and so on.
The xslt that I currently have applies the prediction class to all the elements (i think) for some reason it is not honoring the start-with condition. I have to use xsl choose as we will be adding more elements in future and I feel that will be the best way to check for addition elements in future.
Thank you for your time.
Edit1: Final HTML Output
<div id="_6cf44f92-1de1-4603-a4a7-1ac2e2020508" class="key-point">
<p>
<b>KEY POIINT</b>: There are four basic types of curation that L&D departments should leverage: traditional, self, machine, and social.
</p>
</div>
<p>
</p>
<div id="_b0ec8f84-65ea-4590-a1da-ee6f79a2af67" class="key-point">
<p>
<b>ANALYSIS</b>: There are four basic types of curation that L&D departments should leverage: traditional, self, machine, and social.
</p>
</div>
<p>
</p>
<p>
</p>
<div id="_72ced280-a2fe-499b-af54-c32c1414f7e1" class="key-point">
<p>
<b>PREDICTION</b>: There are four basic types of curation that L&D departments should leverage: traditional, self, machine, and social. There are four basic types of curation that L&D departments should leverage: traditional, self, machine, and social.
</p>
</div>