Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1092633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:42:47+00:00 2026-05-16T23:42:47+00:00

I got really close this time ;) Bellow there is : my xsl script

  • 0

I got really close this time 😉

Bellow there is :

  1. my xsl script
  2. my xml file (that calls the script)

  3. the output of the manipulation of the xsl on the xml (as shuold be)

My problem is that while the href and src value should be the same there is always one
picture diff between them(pic3 and pic4) as though I’m calling the next pic element… yet I dont understand where I do that?

 <xsl:for-each select="data/pics/pic">
        <div>                   
            <a>
                <xsl:attribute name="href">
                    <xsl:value-of select="@href" />
                </xsl:attribute>
                <img>
                    <xsl:attribute name="src">
                        <xsl:value-of select="@src" />
                    </xsl:attribute>

                </img>
            </a>
        </div>
    </xsl:for-each>

And this is my xml

<data>
    <pics>
        <pic href="pics\pic05.jpg" src="pics\pic05.jpg"></pic>
        <pic href="pics\pic04.jpg" src="pics\pic04.jpg"></pic>
        <pic href="pics\pic03.jpg" src="pics\pic03.jpg"></pic>
        <pic href="pics\pic02.jpg" src="pics\pic02.jpg"></pic>
        <pic href="pics\pic01.jpg" src="pics\pic01.jpg"></pic> 
    </pics> 
</data> 

this should be the output:

<div>
    <a href="pics\pic01.jpg">
        <img src="pics\pic01.jpg">
    </a>
</div>
<div>
    <a href="pics\pic02.jpg">
        <img src="pics\pic02.jpg">
    </a>
</div>
<div>
    <a href="pics\pic03.jpg">
        <img src="pics\pic03.jpg">
    </a>
</div>
<div>
    <a href="pics\pic04.jpg">
        <img src="pics\pic04.jpg">
    </a>
</div>
<div>
    <a href="pics\pic05.jpg">
        <img src="pics\pic05.jpg">
    </a>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:42:47+00:00Added an answer on May 16, 2026 at 11:42 pm

    THe XSLT processor you are using may have a bug, or you haven’t provided the real xslt code and xml document.

    The provided XSLT code fragment when included in a complete stylesheet:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
     <xsl:template match="/">
      <html>
         <xsl:for-each select="data/pics/pic">
                <div>
                    <a>
                        <xsl:attribute name="href">
                            <xsl:value-of select="@href" />
                        </xsl:attribute>
                        <img>
                            <xsl:attribute name="src">
                               <xsl:value-of select="@src" />
                            </xsl:attribute>
                        </img>
                    </a>
                </div>
            </xsl:for-each>
      </html>
     </xsl:template>
    </xsl:stylesheet>
    

    and applied on the provided XML document:

    <data>
        <pics>
            <pic href="pics\pic05.jpg" src="pics\pic05.jpg"></pic>
            <pic href="pics\pic04.jpg" src="pics\pic04.jpg"></pic>
            <pic href="pics\pic03.jpg" src="pics\pic03.jpg"></pic>
            <pic href="pics\pic02.jpg" src="pics\pic02.jpg"></pic>
            <pic href="pics\pic01.jpg" src="pics\pic01.jpg"></pic>
        </pics>
    </data>
    

    produces the wanted, correct result:

    <html>
        <div>
            <a href="pics\pic05.jpg">
                <img src="pics\pic05.jpg"/>
            </a>
        </div>
        <div>
            <a href="pics\pic04.jpg">
                <img src="pics\pic04.jpg"/>
            </a>
        </div>
        <div>
            <a href="pics\pic03.jpg">
                <img src="pics\pic03.jpg"/>
            </a>
        </div>
        <div>
            <a href="pics\pic02.jpg">
                <img src="pics\pic02.jpg"/>
            </a>
        </div>
        <div>
            <a href="pics\pic01.jpg">
                <img src="pics\pic01.jpg"/>
            </a>
        </div>
    </html>
    

    This transformation produced the same result when performed with several different XSLT processors, such as MSXML3,4,6, Saxon6.5 and AltovaXML (XML-SPY).

    Do note, that the transformation can be refactored into a much shorter and readable one:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
     <xsl:template match="/">
      <html>
         <xsl:for-each select="data/pics/pic">
                <div>
                    <a href="{@href}">
                        <img src="{@src}"/>
                    </a>
                </div>
            </xsl:for-each>
      </html>
     </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this really simple piece of code that I thought was the correct
I've got one really big .java class file that has a lot of members.
I've got the following code - this is the first time I've really attempted
I've got a really odd error message that only occurs when I add the
I've got a really simple class that is giving a strange error. The class
Morning all, Theres a few questions around this but none that really answer my
I face a very serious situation. By writing this question I hope that really
I have some code that has got me very close to what Im trying
Concerning my previous question , I found out that maven can't really output jboss
I read this and got really interested: Validating date format using regular expression so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.