How can I read an element/ tag like below - using xsl + xpath, I am trying to format the xml output to read the alignment tag from the style attribute, but I cannot figure it out... (last resort c#)
EDIT: To make my answer clear, I could be reading many html documents, I will most likely have a list of allowed tags that I need parsing so not everything will need parsing, as I am using xslt to transfortm teh document into xml I am writing my solution so far keeping only xsl + xpath in mind, however if I was to use c# and linq (to iterate over the document) - obviously that will set up all the styles then I will transform my document with other additions.
<h1 style="text-align: right;">Another chapter</h1>
My Xsl:
<xsl:template match="h1">
<fo:block color="black" font-family="Arial, Verdana, sans-serif">
<xsl:call-template name="set-alignment"/>
</fo:block>
</xsl:template>
<xsl:template name="set-alignment">
<xsl:choose>
<xsl:when test="@align='left'">
<xsl:attribute name="text-align">start</xsl:attribute>
</xsl:when>
<xsl:when test="@align='center'">
<xsl:attribute name="text-align">center</xsl:attribute>
</xsl:when>
<xsl:when test="@align='right'">
<xsl:attribute name="text-align">end</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>
Note, there is only one style defined below, but there could be many... (underline etc.)
Desired output:
<h1 text-align="start" text-decoration="underline" >Another chapter</h1>