Jump to content

karamba

Members
  • Posts

    1
  • Joined

  • Last visited

karamba's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hello, I'm rather new in the xml world and I have a problem setting up an appropriate xslt to translate some node content into numeric values and to create a sum for each record. Here's how the sample xml file looks like: <record 1> <title>title 1</title> <note type="tags"> <note type="tag">text A</note> </note></record><record 2> <title>title 2</title> <note type="tags"> <note type="tag">text A</note> <note type="tag">text B</note> <note type="tag">text C</note> </note></record><record 3> <title>title 3</title> <note type="tags"> <note type="tag">text A</note> <note type="tag">text C</note> </note></record> What I would like to do is to transform some of the "note" values into numeric values (for a database) and make one sum for each dataset. "text A" should return "1" "text B" should return "2" "text C" should return "4" and so on resulting in something like this: </Record 1><sum>1</sum></Record 1></Record 2><sum>7</sum></Record 2></Record 3><sum>5</sum></Record 3> But I got stuck how to capture the values for each dataset for further processing, namely to create a sum for each.There is more information extracted from "note" values, which are simply compared to certain values with an <xsl: if test="contains(note, 'value')"> or <xsl: if ="starts with(note, 'value')"> outputting a numeric value as <xsl:text>. As can be seen below: <xsl:choose> <xsl:when test="note"> <xsl:choose> <xsl:when test="contains(note, 'text y')"> <xsl:text>128</xsl:text> </xsl:when> <xsl:when test="contains(note, 'text z')"> <xsl:text>256</xsl:text> </xsl:when></xsl:choose> Could you help me? I am grateful for any suggestions.Thank you
×
×
  • Create New...