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

RE: Arrays

Subject: RE: Arrays
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Thu, 20 Jan 2005 13:54:44 -0000
xsl arrays
> I'd like my xsl read a txt file, like this:
>
>
> ------file.txt---------------
>
> 10101010101010101111010101010
> 10101011100001010101010101010
> 00011010101010101010101011011
>
> -----------------------------
>
> So, I used the unparsed-text() function, and my xml
> was like this:
>
> <matrix>
> 10101010101010101111010101010
> 11101011100001010101010101010
> 00011010101010101010101011011
> </matrix>
>
>
> Now I need to put each binary number (0 and 1) of
> matrix in a structured like this:
>
> <matrix>
> <row>
>   <cell>1</cell>
>   <cell>0</cell>
>   ...
> </row>
>
> <row>
>   <cell>1</cell>
>   <cell>1</cell>
>   ...
> </row>
> ...
> <matrix>
>
>
> Is it possible I read each number?
>
> How could I do this in XSLT?


<matrix>
	<xsl:analyze-string select="$in" regex="\n">
		<xsl:non-matching-substring>
			<row>
				<xsl:analyze-string select="."
regex=".">
					<xsl:matching-substring>
						<cell>
							<xsl:value-of
select="."/>
						</cell>
					</xsl:matching-substring>
				</xsl:analyze-string>
			</row>
		</xsl:non-matching-substring>
	</xsl:analyze-string>
</matrix>

Where $in contains the result of the unparsed-text() call.

cheers
andrew

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.