Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
429 views
in Technique[技术] by (71.8m points)

xslt - Extracting some data from XML

<block1>
  <tag>
    <name>59</name>
    <value>/00940001812410930828 FONDITEL VALORES AV SAU ATAM PEDRO TEIXERIA 8 PLANTA 7A 28020MADRID
    </value>
  </tag>
</block1>

I need the output as 00940001812410930828 ,FONDITEL VALORES AV SAU ATAM PEDRO TEIXERIA 8 PLANTA 7A 28020MADRID

Can any one help me please?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If I'm not missing anything try the following approach:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="//value">
        <xsl:value-of select="substring-after('/', normalize-space(.))"/>
    </xsl:template>
</xsl:stylesheet>

In case you want to concentrate on string processing you should probably consider improving your xml markup instead of that. Otherwise working with string values with xslt 1.0 is tedious. (if you're using 2.0 then there is a list of predefined functions exactly for this purpose (like fn:tokenize).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...