I have an XML that looks like this:
& lt; Field index = "1" name = "my_field_1" type = "string" & gt; & Lt; Value & gt; Value of field 1 & lt; / Value & gt; & Lt; / Region & gt; & Lt; Field index = "2" name = "my_field_2" type = "string" & gt; & Lt; Value & gt; Value of field 2 & lt; / Value & gt; & Lt; / Region & gt; & Lt; Field index = "3" name = "my_field_3" type = "string" & gt; & Lt; Value & gt; Value of field 3 & lt; / Value & gt; & Lt; / Region & gt; For each subsequent I repeat on those areas and I try to name the area (which is the same) and it can be included with the index attribute (which can be different depending on the number of elements). is. . I tried to do it (I put it in the apostry variable because I was not sure how I can escape it).
& lt; Xsl: variable name = "currentIndex" select = "@index" & gt; & Lt; / XSL: variable & gt; & Lt; Xsl: variable name = "apostrof" & gt; '& Lt; / Xsl: variable & gt; & Lt; Xsl: value-select = "cockat ('// field [@names =', $ astropof, 'sar_account_product_name_', @ index, apodropof, '] / value')" /> The problem is that instead of the selection value it only produces string my_field_1 for example The value of output field 1 should be, value of field 2 etc. I need instead to combine the name attribute with dynamically the index attribute.
The following changes
& lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Xsl: conversion version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform"> & Lt; Xsl: template match = "/" & gt; & Lt; Xsl: each selection = "field" & gt; & Lt; Xsl: Select Value = "Value" /> & Lt; / XSL: for-each & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: Conviction & gt; Applies to this input
& lt ;? XML version = "1.0"? & Gt; Produces the desired output of the value of the field value of 1 field 2 value of field 2 I hope it helps, otherwise give me a hint in a comment.
Comments
Post a Comment