[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Encoding base64 with XSLT

Subject: RE: Encoding base64 with XSLT
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 19 Aug 2004 10:34:33 +0100
xsl base64
No, this can only be done using an extension function (or some very tortuous
low-level code). This is true even in XSLT 2.0/XPath 2.0, which supports the
xs:base64Binary data type but doesn't provide any function to get from a
sequence of octets to a base64Binary value.

I found that the following works with my current build of Saxon 8.1:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xmlns:b64="net.sf.saxon.value.Base64BinaryValue"
exclude-result-prefixes="b64">
  <xsl:template match="/">
    <out>
      <a><xsl:value-of
select="b64:new(string-to-codepoints('M|ller'))"/></a>
    </out>
  </xsl:template>
</xsl:stylesheet>

Unfortunately it doesn't work with Saxon 8.0 because the mapping of an XPath
sequence of integers to a Java byte[] array isn't picked up: a different
constructor is selected instead. The basic code is there in Saxon, but
you'll have to write a Java wrapper method to invoke it.

I'll probably package this as a documented extension function in due course.

Michael Kay

> -----Original Message-----
> From: Michael Wiedmann [mailto:michael.wiedmann@xxxxxxxxx]
> Sent: 19 August 2004 10:05
> To: XSL List
> Subject:  Encoding base64 with XSLT
>
> An XML based addressbook has to be converted to LDIF (LDAP Data
> Interchange Format, RFC 2849) using an XSLT-stylesheet. LDIF does not
> allow non-ASCII characters, they have to be base64-encoded.
>
> E.g. given an element
>
> <lastname>M|ller</lastname>
>
> has to be written like
>
> sn:: TfxsbGVy
>
> instead of simply:
>
> sn: M|ller
>
> Is there any way to encode base64 with XSLT
>
> Michael

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.