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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:06:08+00:00 2026-06-11T10:06:08+00:00

Using XSLT transformation I want to convert an XML file, that in turn represents

  • 0

Using XSLT transformation I want to convert an XML file, that in turn represents various chunks of another file, into a HTML file with a link to the file that was represented.

Input XML File:

<File>
  <Name>foo.jpg<Name>
  <Chunk>
      <Offset>200</Offset>
      <Length>100</Length>
      <Data>
          <![CDATA[data bytes, encoded in base64, can be greater than length 100 too, but first 100 decoded bytes are valid.]]>
      </Data>
  </Chunk>
  <Chunk>
  ...
</File>

The output should be a html file that has a valid link to foo.jpg, i.e., there is another implicit output file called “foo.jpg” with data from the cdata sections in the chunks, at their specified offsets.

<html>
   <body>
      <a href="http://example.com/images/foo.jpg">file</a>
   </body>
</html>

Related question

  • 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-11T10:06:09+00:00Added an answer on June 11, 2026 at 10:06 am

    This XSLT 2.0 transformation:

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/*">
    
      <xsl:document>
            <html>
               <body>
                  <a href="http://example.com/images/{Name}">file</a>
               </body>
            </html>
      </xsl:document>
    
      <xsl:result-document href="file:///c:/temp/delete/{Name}" method="text">
        <xsl:apply-templates select="Chunk">
         <xsl:sort select="Offset" data-type="number"/>
        </xsl:apply-templates>
      </xsl:result-document>
     </xsl:template>
    
     <xsl:template match="Chunk">
      <xsl:value-of select="substring(Data, 1, Length)"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on this XML document (having two chunks):

    <File>
      <Name>foo.jpg</Name>
      <Chunk>
          <Offset>200</Offset>
          <Length>100</Length>
          <Data>A01234567891234567890234567890134567890124567890123567890123467890123457890123456890123456790123456780123456789</Data>
      </Chunk>
      <Chunk>
          <Offset>1</Offset>
          <Length>200</Length>
          <Data>Z0123456789123456789023456789013456789012456789012356789012346789012345789012345689012345679012345678012345678901234567891234567890234567890134567890124567890123567890123467890123457890123456890123456790123456780123456789</Data>
      </Chunk>
    </File>
    

    produces the wanted, correct result:

    <html>
       <body><a href="http://example.com/images/foo.jpg">file</a></body>
    </html>
    

    and the created file: c:\temp\delete\foo.jpg has the correct, wanted contents:

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

Sidebar

Related Questions

I am trying to convert an HTML file into XML file using XSLT (Using
I am using XSLT to convert a very large XML document into (X)HTML. For
I'm using XSLT 1.0 an want to transform an XML file. It works fine
I'm trying to post-process the documentation XML file as a post-build XSLT transformation (using
I am writing an application that converts an ajax xml response into html using
I am transforming XML into HTML using XSLT. I have the following XML structure:
I am using xslt 2.0 for transforming one xml format to another xml format.But
I'm using xslt do display Solr response in html, my xsl file is in
I'm using an XsltCompiledTransform to transform some XML into a fragment of HTML (not
I'm trying to extract some information from an xml file using xslt. I've used

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.