473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Cleaning out my disk

Hi all,

While getting ready to get rid of an old computer of mine, I came across
this transform that I wrote a few years ago (around 2002 I think). I did
it just to prove that it could be done, so the more mathematically
inclined will no doubt find better ways to do this.

I thought some of you might get a kick out of it.

Do this:

1) Run it trough your favorite XSLT 1.0 processor, output to file. I
recommend a really fast processor, such as SAXON. The transform does not
depend on any input source, so you can use whatever you have lying
around. Wait for it...

2) Open the result in a browser. Wait for it...
Here is the transform:

-- begin mandel.xsl --

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"
indent="yes"
encoding="iso-8859-1"/>

<!-- The area to calculate -->
<xsl:param name="minX" select="-2"/>
<xsl:param name="maxX" select="1.25"/>
<xsl:param name="minY" select="-1.25"/>
<xsl:param name="maxY" select="1.75"/>

<!-- Maximum number of iterations -->
<xsl:param name="maxIterations" select="100"/>

<!-- Cell size -->
<xsl:param name="cellSize" select="1"/>

<!-- Number of rows -->
<xsl:param name="rowsMax" select="300"/>

<xsl:variable name="dy" select="($maxY - $minY) div $rowsMax"/>
<xsl:variable name="cellsMax" select="($maxX - $minX) div $dy"/>
<xsl:variable name="dx" select="($maxX - $minX) div $cellsMax"/>

<xsl:template match="/">
<html>
<head>
<title>XSLT Mandelbrot Set</title>
</head>
<body>
<table cellspacing="0"
cellpadding="0"
border="0"
bgcolor="black">
<xsl:call-template name="Rows"/>
</table>
</body>
</html>
</xsl:template>

<xsl:template name="Rows">
<xsl:param name="rowNumber" select="0"/>
<xsl:if test="$rowNumber &lt; $rowsMax">
<xsl:message>
<xsl:value-of select="concat('Row ', $rowNumber + 1, ' of ',
$rowsMax)"/>
</xsl:message>
<tr>
<xsl:call-template name="Cells">
<xsl:with-param name="rowNumber" select="$rowNumber"/>
</xsl:call-template>
</tr>
<xsl:call-template name="Rows">
<xsl:with-param name="rowNumber" select="$rowNumber + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template name="Cells">
<xsl:param name="cellNumber" select="0"/>
<xsl:param name="rowNumber"/>
<xsl:if test="$cellNumber &lt; $cellsMax">
<td width="{$cellSize}" height="{$cellSize}">
<xsl:call-template name="CellColor">
<xsl:with-param name="cx" select="$minX + ($cellNumber * $dx)"/>
<xsl:with-param name="cy" select="$minY + ($rowNumber * $dy)"/>
</xsl:call-template>
</td>
<xsl:call-template name="Cells">
<xsl:with-param name="cellNumber" select="$cellNumber + 1"/>
<xsl:with-param name="rowNumber" select="$rowNumber"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template name="CellColor">
<xsl:param name="iteration" select="0"/>
<xsl:param name="cx"/>
<xsl:param name="cy"/>
<xsl:param name="a0" select="0"/>
<xsl:param name="b0" select="0"/>
<xsl:variable name="a1" select="($a0 * $a0) - ($b0 * $b0) + $cx"/>
<xsl:variable name="b1" select="2 * ($a0 * $b0) + $cy"/>
<xsl:variable name="zLength" select="($a1 * $a1) + ($b1 * $b1)"/>
<xsl:if test="$zLength &gt; 4">
<xsl:variable name="color">
<xsl:call-template name="Dec2Hex">
<xsl:with-param name="dec" select="round((16777215 div
$maxIterations) * $iteration)"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="padding"
select="6 - string-length($color)"/>
<xsl:variable name="paddedColor"
select="concat(substring('000000',1,$padding), $color)"/>
<xsl:attribute name="bgcolor">
<xsl:value-of select="concat('#',$paddedColor)"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$iteration &lt; $maxIterations and $zLength &lt;= 4">
<xsl:call-template name="CellColor">
<xsl:with-param name="iteration" select="$iteration + 1"/>
<xsl:with-param name="cx" select="$cx"/>
<xsl:with-param name="cy" select="$cy"/>
<xsl:with-param name="a0" select="$a1"/>
<xsl:with-param name="b0" select="$b1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template name="Dec2Hex">
<xsl:param name="dec" select="0"/>
<xsl:variable name="div" select="floor($dec div 16)"/>
<xsl:variable name="rem" select="$dec - ($div * 16)"/>
<xsl:choose>
<xsl:when test="$dec = 0">0</xsl:when>
<xsl:when test="$dec = 1">1</xsl:when>
<xsl:when test="$dec = 2">2</xsl:when>
<xsl:when test="$dec = 3">3</xsl:when>
<xsl:when test="$dec = 4">4</xsl:when>
<xsl:when test="$dec = 5">5</xsl:when>
<xsl:when test="$dec = 6">6</xsl:when>
<xsl:when test="$dec = 7">7</xsl:when>
<xsl:when test="$dec = 8">8</xsl:when>
<xsl:when test="$dec = 9">9</xsl:when>
<xsl:when test="$dec = 10">A</xsl:when>
<xsl:when test="$dec = 11">B</xsl:when>
<xsl:when test="$dec = 12">C</xsl:when>
<xsl:when test="$dec = 13">D</xsl:when>
<xsl:when test="$dec = 14">E</xsl:when>
<xsl:when test="$dec = 15">F</xsl:when>
<xsl:otherwise>
<xsl:call-template name="Dec2Hex">
<xsl:with-param name="dec" select="$div"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$div">
<xsl:call-template name="Dec2Hex">
<xsl:with-param name="dec" select="$rem"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

</xsl:stylesheet>

-- end mandel.xsl --

Other mildly interesting values of the parameters are:

minX = 0.2
maxX = 0.4
minY = 0.5
maxY = 0.7

and

minX = 0.3
maxX = 0.4
minY = 0.5
maxY = 0.6

and

minX = 0.32
maxX = 0.35
minY = 0.52
maxY = 0.55

The smaller the area, the longer it will take. For really small areas it
seems like the processor gets stuck.
// Magnus
Oct 20 '06 #1
3 1449
And I thought merely solving the eight-queens problem in XSLT was a
terrifying concept... <grin/>

Are you willing to officially put that into the public domain so we can
pass it around?
Oct 20 '06 #2
Joseph Kesselman wrote:
And I thought merely solving the eight-queens problem in XSLT was a
terrifying concept... <grin/>

Are you willing to officially put that into the public domain so we can
pass it around?
I hereby abandon any property rights to the XSLT code in message
eh**********@news.al.sw.ericsson.se.

// Magnus
Oct 20 '06 #3

Magnus Henriksson wrote:

[XSLT Mandelbrot Set Explorer]
I thought some of you might get a kick out of it.
I sure did.
1) Run it trough your favorite XSLT 1.0 processor, output
to file. I recommend a really fast processor, such as
SAXON.
libxslt-based PHP5 module worked well enough for me. (And I
didn't even have to juggle the files around - my web-based
toolkit handles that for me and displays the transformation
result in an iframe.)

I guess this post is a bit pointless, but I just wanted to
say that this is wonderful stuff. Hats off.

--
roy axenov

Oct 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: StinkFinger | last post by:
Hello all, After enabling sessions for my website I have approx. 785 files in my sessiondata folder. Now, I know what these are, however, I don't know when/how is the best way to clean them...
2
by: Ellen K. | last post by:
What tools has everyone used for cleaning name and address data (including identifying not-immediately-obvious duplicates) in connection with a CRM project or the Customer dimension of a data...
1
by: Matej Cepl | last post by:
Hi, can anybody help me with the cleaning of really messy HTML from the news site into really clean XHTML, which I would like to then analyze with some qualitative analysis (probably exporting...
4
by: Jaans | last post by:
I have a problem that relates to running "cleanup" code when an application is forcibly ended using the "End Process" of "Task Manager" (Please note that this is very different from "End Task"...
6
by: sheffdog | last post by:
Hello, I often find myself cleaning up strings like the following: setAttr ".ftn" -type "string" /assets/chars/ /boya/geo/textures/lod1/ppbhat.tga"; Using regular expressions, the best I...
3
by: Pierre Saint-Jacques | last post by:
DB2 V8.2 has a new envir. var. DB2_USE_ALTERNATE_PAGE_CLEANING=YES The docs. mention that this will make DB2 ignore chngpgs_thresh and use softmax to even the rate of writing out of the bp's. ...
13
by: jadionne | last post by:
I have a new instalation that I am ironing out the wrinkles in. In the process I have had a few crashes and now my SQLlib\DB2 Dir is full of ..0 and .000 files. What is the best way to clean up...
1
by: Mikey | last post by:
Do NativeWindows get destroyed when the app shuts down? While my app is running I can Spy++ and see my NativeWindow handle. After app shutdown it's no longer there. But this is confusing...
8
by: Foodbank | last post by:
Hi, Has anyone ever hashed a text file to disk before? I'm trying to convert an in-memory hash to disk hash and I can't find any relevant information to help me. Also, I'd like to use lseek,...
0
by: Now You Know | last post by:
Carpet Cleaners Los Angeles Home Carpet Rug Upholstery Cleaning Phone 1 310 925 1720 OR 1-818-386-1022 Local Call California Wide We offer carpet cleaning services such as; Steam Cleaning, Dry...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.