xslt - any restriction with the length of Metadata name? -


i new forum. need parse/read xml cotains lots of metadata(as below). have 2 read specific meta value based on bu value, example if bu value '987654321abcdefghijklmnopaslasjdoiwneois123abc' have value "d581452fa9ba3110vgnvcm10000038ccc5abrcrd|def". question, there restriction metadata name length? reason xslt logic not reading value(select="mt[@n=$partialval]/@v").

xslt snippet:

   <xsl:for-each select='./mt[@n="bu"]'>   <xsl:variable name="temp_bu" select="./@v"/>   <xsl:variable name="partialval" select="'987654321abcdefghijklmnopaslasjdoiwneois123abc'"/>   <xsl:if test="contains($partialval, $temp_bu)">     <xsl:variable name="partialbuval" select="mt[@n=$partialval]/@v"/>     <xsl:value-of disable-output-escaping='yes' select="concat('file://',$partialbuval,'test',$partialval)"/>   </xsl:if>    </xsl:for-each> 

sample xml structure:

    <mt n="bu" v="12345678910111121314sdnfske34234123234abc"/>     <mt n="12345678910111121314sdnfske34234123234abc" v="02715148a3e7a110vgnvcm1000001b89c5abrcrd|abc"/>     <mt n="12345678910111121314sdnfske34234123234abc_name" v="item one"/>     <mt n="bu" v="987654321abcdefghijklmnopaslasjdoiwneois123abc"/>     <mt n="987654321abcdefghijklmnopaslasjdoiwneois123abc" v="d581452fa9ba3110vgnvcm10000038ccc5abrcrd|def"/>     <mt n="987654321abcdefghijklmnopaslasjdoiwneois123abc_name" v="item two"/>     <mt n="bu" v="qqqqqwwwweeeee1112223333ssdfff3334sssssabc"/>     <mt n="qqqqqwwwweeeee1112223333ssdfff3334sssssabc" v="d581452fa9ba3110vgnvcm10000038ccc5abrcrd|ghi"/>     <mt n="qqqqqwwwweeeee1112223333ssdfff3334sssssabc_name" v="item three"/>     <mt n="bu" v="hhhheeeertisodfnsdifwoein12345sfjsoif234defgh"/>     <mt n="hhhheeeertisodfnsdifwoein12345sfjsoif234defgh" v="d581452fa9ba3110vgnvcm10000038ccc5abrcrd|jkl"/>     <mt n="hhhheeeertisodfnsdifwoein12345sfjsoif234defgh_name" v="item four"/> 

seeing output (partialbuval value missing in string) "file://test987654321abcdefghijklmnopaslasjdoiwneois123abc"

i not sure mistake doing here. appreciate if me.

thanks, amarnath

i not sure understand requirement. in following:

<xsl:for-each select="./mt[@n="bu"]">    <xsl:variable ... select="mt[@n=$partialval]/@v"/> </xsl:for-each> 

the second select never select anything. because xsl:for-each changes context. within body of xsl:for-each (also called sequence constructor) context item current mt element being looked at in current iteration of xsl:for-each.

so second select expression asks any mt element, direct child of current mt element, , there not any.

extra tip: ./ @ beginning of xpath expression meaningless. situation starting expression dot .//. ./mt equivalent mt, more readable.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -