xml - Transforming an argument's contents with xslt -
i have xml document structure like:
<report> <row> <field raw="<table> <tr> <td> r1c1 </td> <td> r1c2 </td> </tr> </table>" /> </row> </report>
i can not directly change xml document far can tell, , can update raw attribute value. transform value way transform xml contents itself, rather showing contents:
"<table><tr><td>r1c1</td><td>r1c2</td></tr></table>"
i can instead match transform tags within contents generate corresponding fo tags pdf output, akin being able set template match like:
<xsl:template match="//report/row/field/attribute::raw/table/"> <fo:table> <xsl:for-each select="../tr"> <fo:table-row> <xsl:for-each select="../td"> <fo:table-cell> <xsl:value select= "../" /> </fo:table-cell> </xsl:for-each> </fo:table-row> </xsl:for-each> </fo:table> </xsl:template>
obviously not work, contents of attribute not treated xml nodes , < , > escaped, can't matched in quite same way. apologies if still misunderstanding core concepts in request, i'm still relatively new xslt , xpath, i'm not sure if i'm asking quite right question. i'm open different approach, though i'm trying avoid parsing string value directly. i'll gladly provide clarification wherever needed.
using xslt 3.0 supported in saxon 9.7 or higher or altova xml spy can use
<xsl:template match="field/@raw"> <xsl:apply-templates select="parse-xml(.)/table"/> </xsl:template> <xsl:template match="table"> <fo:table> <xsl:apply-templates/> </fo:table> </xsl:template> <xsl:template match="tr"> <fo:table-row> <xsl:apply-templates/> </fo:table-row> </xsl:template> ...
Comments
Post a Comment