| |

VerySource

 Forgot password?
 Register
Search
View: 987|Reply: 4

xsl loop output problem

[Copy link]

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-14 10:00:01
| Show all posts |Read mode
XML file:

    <note>
      <id> 1 </ id>
      <name> Zhang Chao </ name>
      <code> 1111111 </ code>
      <tel> </ tel>
    </ note>
    <note>
      <id> 2 </ id>
      <name> Wang San </ name>
      <code> 2222222 </ code>
      <tel> </ tel>
    </ note>
    <note>

The HTML file that needs to be output through XSL is as follows:

 <tr>
     <td> 1 </ td>
     <td> Zhang Chao </ td>
     <td> 1111111 </ td>
     <td> <input type = "text" style = "WIDTH: 100%;" id = "tel1"> </ td>
  </ tr>
  <tr>
     <td> 2 </ td>
     <td> Wang San </ td>
     <td> 2222222 </ td>
     <td> <input type = "text" style = "WIDTH: 100%;" id = "tel2"> </ td>
  </ tr>
Reply

Use magic Report

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-7-26 00:00:01
| Show all posts
No one knows?

I just want to know how to write the attribute id in the input looped out in XSL every time it increments by +1

id="tel1"

id="tel2"

id="tel3"

That's it, because it is the result of the loop, if the ID does not change, then everything will be the same
Reply

Use magic Report

1

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-8-13 10:45:01
| Show all posts
<xsl:element name="input">
<xsl:attribute name="type">text</xsl:attribute name>
<xsl:attribute name="id">It seems that there is a built-in function that can be called to change the ID</xsl:attribute name>
</xsl:element>
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-13 17:00:01
| Show all posts
<xsl:element name="input">
<xsl:attribute name="type">text</xsl:attribute name>
<xsl:attribute name="id">txt<xsl:value-of select="position()"/></xsl:attribute name>
</xsl:element>

or:
<input type="text" id="txt{position()}"/>
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-14 11:15:01
| Show all posts
I just write the key code: use the xsl attribute for-each statement:
xsl file (foreach.xsl)
...
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
...
<xsl:for-each select="note">
<TR>
<TD><xsl:value-of select="id"></TD>
<TD><xsl:value-of select="name"></TD>
<TD><xsl:value-of select="code"></TD>
<TD><xsl:value-of select="tel"></TD>
</TR>
</xsl:for-each>
xml file
<?xml-stylesheet type="text/xsl" href="foreach.xsl"?>
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list