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 9104175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:48:14+00:00 2026-06-17T01:48:14+00:00

I’m muddling my way through learning XSLT and have a challenge where I need

  • 0

I’m muddling my way through learning XSLT and have a challenge where I need ultimately to filter and sort over 100 products that I can only retrieve 20 at a time from a webservice. I have been able to pull those products successfully and manipulate them but only in their original batches, not as if they are one list. So I’ve tried to transform the separate files into one as follows.

Combining multiple files like this one:

A.xml

<?xml version="1.0" encoding="UTF-8"?>
<productSearchResponse>
    <products>
        <product>
            <code>A1</code>
            <item> SAUVIGNON RESERVA</item>
            <country>Spain</country>
            <region>Penedes</region>
            <category>Red</category>
            <style>Full-bodied</style>
        </product>
        <product>
            <code>A2</code>
            <item>RESERVE RIESLING</item>
            <country>France</country>
            <region>Alsace</region>
            <category>White</category>
            <style>Aromatic</style>
        </product>
        <product>
            <code>A3</code>
            <item>GAMAY</item>
            <country>Canada</country>
            <region>Ontario</region>
            <category>Red</category>
            <style>Medium-bodied</style>
        </product>
    </products>
</productSearchResponse>

… with this one:

B.xml

<?xml version="1.0" encoding="UTF-8"?>
<productSearchResponse>
    <products>
        <product>
            <code>B1</code>
            <item>BOURGOGNE CHARDONNAY</item>
            <country>France</country>
            <region>Burgundy</region>
            <category>White</category>
            <style>Light</style>
        </product>
        <product>
            <code>B2</code>
            <item>ONTARIO RIESLING II</item>
            <country>Canada</country>
            <region>Ontario</region>
            <category>White</category>
            <style>Off-dry</style>
        </product>
        <product>
            <code>B3</code>
            <item>WEST COAST CAB SAUV</item>
            <country>USA</country>
            <region>California</region>
            <category>Red</category>
            <style>Full-bodied</style>
        </product>
    </products>
</productSearchResponse>

…to get a new xml file that looks like this one:
all.xml

<?xml version="1.0" encoding="UTF-8"?>
<productSearchResponse>
    <products>
        <product>
            <code>A1</code>
            <item> SAUVIGNON RESERVA</item>
            <country>Spain</country>
            <region>Penedes</region>
            <category>Red</category>
            <style>Full-bodied</style>
        </product>
        <product>
            <code>A2</code>
            <item>RESERVE RIESLING</item>
            <country>France</country>
            <region>Alsace</region>
            <category>White</category>
            <style>Aromatic</style>
        </product>
        <product>
            <code>A3</code>
            <item>GAMAY</item>
            <country>Canada</country>
            <region>Ontario</region>
            <category>Red</category>
            <style>Medium-bodied</style>
        </product>
        <product>
            <code>B1</code>
            <item>BOURGOGNE CHARDONNAY</item>
            <country>France</country>
            <region>Burgundy</region>
            <category>White</category>
            <style>Light</style>
        </product>
        <product>
            <code>B2</code>
            <item>ONTARIO RIESLING II</item>
            <country>Canada</country>
            <region>Ontario</region>
            <category>White</category>
            <style>Off-dry</style>
        </product>
        <product>
            <code>B3</code>
            <item>WEST COAST CAB SAUV</item>
            <country>USA</country>
            <region>California</region>
            <category>Red</category>
            <style>Full-bodied</style>
        </product>
    </products>
</productSearchResponse>

I have tried using this

ABC.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="ABC.xsl"?>
<essentials>
    <webservice filename="A.xml"/>
    <webservice filename="B.xml"/>
    <!-- etc -->
</essentials>

with this

ABC.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0"  indent="yes"/>
    <xsl:template match="/">
        <output>
            <xsl:for-each select="/essentials/webservice">
                <xsl:for-each select="document(@filename)/productSearchResponse/products/product">
                    <product>
                        <code>
                            <xsl:value-of select="code"/>
                        </code>
                        <item>
                            <xsl:value-of select="item"/>
                        </item> 
                        <country>
                            <xsl:value-of select="country"/>
                        </country>  
                        <region>
                            <xsl:value-of select="region"/>
                        </region>   
                        <category>
                            <xsl:value-of select="category"/>
                        </category>                 
                        <style>
                            <xsl:value-of select="style"/>
                        </style>
                    </product>              
                </xsl:for-each> 
            </xsl:for-each>
        </output>
    </xsl:template>
</xsl:stylesheet>

…. but end up with this in the browser:

A1 SAUVIGNON RESERVASpainPenedesRedFull-bodiedA2RESERVE RIESLINGFranceAlsaceWhiteAromaticA3GAMAYCanadaOntarioRedMedium-bodiedB1BOURGOGNE CHARDONNAYFranceBurgundyWhiteLightB2ONTARIO RIESLING IICanadaOntarioWhiteOff-dryB3WEST COAST CAB SAUVUSACaliforniaRedFull-bodiedC1BURGUNDY PINOT NOIRFranceBurgundyRedMedium-bodiedC2CALIFORNIAN WHITEUSACaliforniaWhiteOff-dryC3CANADIAN REDCanadaOntarioRedFull-bodied

Firebug shows that behind the scenes the result is the desired xml. Where I’m getting stumped is: How can I get the result into a form that I can use, that I can treat as regular xml and do further transformations upon? And have I found the right approach or am I barking up the wrong tree, making this somehow too complicated?

  • 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-06-17T01:48:15+00:00Added an answer on June 17, 2026 at 1:48 am

    Well XML to XML transformation directly in the browser is usually not a good way to use that form of transformation, most browsers or at least Mozilla browsers assume your target format is something like XHTML or SVG the browser knows to render. In your case it is not, so all Firefox does is show the unstyled content of text nodes.

    And of course your code can be simplified:

    <xsl:template match="/">
      <productSearchResponse>
        <products>
          <xsl:copy-of select="document(essentials/webservice/@filename)//product"/>
        </products>
      </productSearchResponse>
    </xsl:template>
    

    That will however not change the rendering in Firefox/Mozilla.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.