image and binary data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maurizio Penna

    image and binary data

    I, guys.

    I've embeded an image into a xml file, something like that:
    <display type="picture" mime="image/png" name = "mosaico6.p ng">
    <![CDATA[ ....my binary data ... ]]>
    </display>

    Now, I want to display it with a XSL Transformation, but my code don't work:
    <display>

    <xsl:attribut e name="mime">
    <xsl:value-of select="@CDATA"/>
    </xsl:attribute>
    </display>

    Can, anyone help me?

    thanks in advance.
    Maurizio.



  • DFN-CIS NetNews Service

    #2
    Re: image and binary data

    On 26/01/2004, around 16:58, Maurizio Penna wrote:

    MP> Now, I want to display it with a XSL Transformation
    A quick search of google suggests you can't although I only spend a
    minute or 2 looking. You might find more there is some discussion
    about doing almost exactly what you're talking about here


    --
    Stuart
    The problem with asking other people for their opinions is that they
    frequently give them!

    Comment

    • Maurizio Penna

      #3
      Re: image and binary data


      "DFN-CIS NetNews Service" <shemming@estat ecomputers.com> ha scritto nel
      messaggio news:1938554649 .20040126170050 @estatecomputer s.com...
      On 26/01/2004, around 16:58, Maurizio Penna wrote:
      [color=blue]
      > A quick search of google suggests you can't although I only spend a
      > minute or 2 looking.[/color]

      Thanks for the help.
      I've spended more than 2 minutes on googles to search something. Your link
      don't solve my problem.

      I'm sorry for my poor english. so I rewrite my problem:
      I must display an image that lives into the xml file, in a CDATA section.
      And I must use a xslt files to display it. I don't now how to say to the
      xslt file that my image is into the CDATA section.

      For your help, I invite you to see this article: Embed binary data in XML
      documents three ways. At
      http://www-106.ibm.com/developerwork...ary/index.html (that
      I've founded with a google's search).
      The second way is my goal, but I don't know, how to construct the xslt file
      (Listing 5. Output format 2: agentproduct2.x ml) to visualize the xml file in
      IE.

      Regards,
      Maurizio.


      Comment

      • DFN-CIS NetNews Service

        #4
        Re: image and binary data

        On 26/01/2004, around 09:24, Maurizio Penna wrote:

        MP> For your help, I invite you to see this article: Embed binary data in XML
        MP> documents three ways.
        In that document you are pointed at the file

        which contains all that was used to generate the example. The author
        seems to use some Java code to do the work. Maybe you'll find the
        answers there.


        --
        Stuart Why is there so much month left at the end of the money?

        Comment

        • Patrick TJ McPhee

          #5
          Re: image and binary data

          In article <newscache$qiy3 sh$wlc$1@listsr v01.csi.it>,
          Maurizio Penna <mauriziopenna_ NO_TUTTO@hotmai l.com> wrote:

          % I'm sorry for my poor english. so I rewrite my problem:
          % I must display an image that lives into the xml file, in a CDATA section.

          You have a problem here. There are certain characters which are likely
          to appear in your image, but which are not permitted in an XML file.
          It doesn't matter whether you put CDATA around them or not -- the
          characters are simply not allowed, and there's nothing you can do about
          it. You can't even use a character reference (� is not permissible,
          for instance). You need to convert to an ascii format when you're embedding
          binary data.

          % And I must use a xslt files to display it. I don't now how to say to the
          % xslt file that my image is into the CDATA section.

          XSLT doesn't know, and shouldn't be able to know, when you're using a CDATA
          section. You need to identify your data by the element of which it's part.
          Having said that, XSLT can be used to extract the image data from your
          original file, but it can't do much with it -- it might be able to
          convert it back to binary format given enough work, but it certainly can't
          display it, and in XSLT 1.0 it can't write each image to a separate file,
          if there's more than one image in the XML file. It doesn't sound like it's
          an appropriate or useful tool for your problem.

          % For your help, I invite you to see this article: Embed binary data in XML
          % documents three ways. At
          % http://www-106.ibm.com/developerwork...ary/index.html (that

          I glanced briefly at this article, and I'd say it's not worth reading.

          What you want to do, and what the author of the article is actually
          doing in his CDATA example (Listing 5), is to convert the binary data into
          MIME base 64 encoding. This is a text format which can be included anywhere
          text is allowed in an XML document. No CDATA section is required.

          When you generate your XML file, you convert the image to mime base64
          (there are libraries for doing this all over the place -- which one you
          use depends on what language you're working with), then include the
          resulting text like any other text.

          <image>/9j/4AAQSkZJRgABAgE ASABIAAD/2wBDABALCwsMCxA MDBAXDw0PFxsUEB AUGx8XFxcXFx8R
          DAwMDAwMEQwMDAw MDAwMDAwMDAwMDA wMDAwMDAwMDAwMD Az/2wBDAREPDxETERU SEhUUDg4O
          ...
          RqhJSQesx30juD8 TsA/ulVPz8zfzTU62+z T6VrKK2tt6IiAsc n3uVPdSYPUtc17m 4MLCxL8w
          IPN96Xwx5kLyvsM g+f5Qb/shHSPEi7w9DGw/4wIDDGzoOkAGxQ7 RSQP/2Q==
          </image>

          when you want to display the image, you get the content of <image>,
          convert it back to binary format, and pass that to the routines that
          display the image.
          --

          Patrick TJ McPhee
          East York Canada
          ptjm@interlog.c om

          Comment

          • DFN-CIS NetNews Service

            #6
            Re: image and binary data

            On 27/01/2004, around 16:12, Patrick TJ McPhee wrote:

            PTM> when you want to display the image, you get the content of <image>,
            PTM> convert it back to binary format, and pass that to the routines that
            PTM> display the image.
            Isn't it possible, say, to generate an multipart HTML document that
            has base64 bits that can be referred to an displayed directly? Or is
            that just a mail thing for attachments?

            --
            Stuart
            Ladies, don't forget the rummage sale. It is a good chance to get rid
            of those things not worth keeping around the house. Bring your
            husbands.

            Comment

            • Patrick TJ McPhee

              #7
              Re: image and binary data

              In article <154487453.2004 0127161417@esta tecomputers.com >,
              DFN-CIS NetNews Service <shemming@estat ecomputers.com> wrote:
              % On 27/01/2004, around 16:12, Patrick TJ McPhee wrote:
              %
              % PTM> when you want to display the image, you get the content of <image>,
              % PTM> convert it back to binary format, and pass that to the routines that
              % PTM> display the image.
              % Isn't it possible, say, to generate an multipart HTML document that
              % has base64 bits that can be referred to an displayed directly? Or is
              % that just a mail thing for attachments?

              multipart mime is purely a mail thing. If one of the parts is html,
              and if you use a mailer which can display it and resolve <img> tags
              to attachments, then you can do that. If you are not writing the code
              to process the XML file, you need to embed the image however the code
              that processes it wants it embedded. XML doesn't inherently have any
              image processing capabilities.


              --

              Patrick TJ McPhee
              East York Canada
              ptjm@interlog.c om

              Comment

              • DFN-CIS NetNews Service

                #8
                Re: image and binary data

                On 28/01/2004, around 17:00, Patrick TJ McPhee wrote:
                PTM> XML doesn't inherently have any
                PTM> image processing capabilities.
                No, I appreciate that, I was thinking more in terms of HTML which
                might be the final output from the XSL transform.

                --
                Stuart
                It is generally inadvisable to eject directly over the area you just
                bombed. - U.S. Air Force Manual

                Comment

                • Patrick TJ McPhee

                  #9
                  Re: image and binary data

                  In article <833363212.2004 0128170129@esta tecomputers.com >,
                  DFN-CIS NetNews Service <shemming@estat ecomputers.com> wrote:
                  % On 28/01/2004, around 17:00, Patrick TJ McPhee wrote:
                  % PTM> XML doesn't inherently have any
                  % PTM> image processing capabilities.
                  % No, I appreciate that, I was thinking more in terms of HTML which
                  % might be the final output from the XSL transform.

                  In the specific case of html, you might be able to use the data:
                  url described in RFC 2397. For instance, you can have

                  <img src='data:image/jpeg;base64,/9j/4AAQSkZJRgABAgE ASABIAAD/7RJC...
                  ...
                  T8Md5MeU9GCbz+S bX7k44U7Crun4Ki n/ACpIXTqKIOElMUk +iSKn/9k='>

                  and if your original XML file has the data as a base-64 encoded
                  jpeg file, xslt can be used to generate this. It will work with some
                  browsers, but not others.
                  --

                  Patrick TJ McPhee
                  East York Canada
                  ptjm@interlog.c om

                  Comment

                  • DFN-CIS NetNews Service

                    #10
                    Re: image and binary data

                    On 29/01/2004, around 08:58, Patrick TJ McPhee wrote:

                    PTM> In the specific case of html, you might be able to use the data:
                    PTM> url described in RFC 2397.
                    Cool. I'll give that a go.

                    PTM> It will work with some browsers, but not others.
                    OK.

                    TVM.

                    --
                    Stuart
                    Sea captains don't like crew cuts.

                    Comment

                    Working...