RE: [xsl] Read a txt file

Subject: RE: [xsl] Read a txt file
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 15 Dec 2004 12:45:39 -0000
> I need my xsl reads a txt file, like this:
> 
> 
> ------file.txt---------------
> 
> 10101010101010101111010101010
> 10101011100001010101010101010
> 00011010101010101010101011011
> 
> -----------------------------
> 
> I'd like to read this values and copy them in a xml
> element:
> 
> <vector>
> 10101010101010101111010101010
> 10101011100001010101010101010
> 00011010101010101010101011011
> </vector>

You can't do that directly in XSLT 1.0. 

In 2.0 it's simply:

<vector>
  <xsl:value-of select="unparsed-text('file.txt')"/>
</vector>

In 1.0 you can pass the contents of the file into the transformation as the
value of a string parameter, or you could use a URIResolver to wrap the text
contents into an XML document structure.
> 
> 
> 
> But I have other problem:
> This values are of a multidimensional vector (matrix).
> 
> 
> In XML, I can't have a element that has a vector
> structure, can I? What could  I do in this case?
> 

<matrix>
  <row>
    <cell>0</cell>
    <cell>1</cell>
  </row>
  <row>
     etc.

Michael Kay
http://www.saxonica.com/

Current Thread