Saturday, June 21, 2008

KnitML

So, I've been starting to play around with KnitML a little bit. For those who are not familiar with it, KnitML is an in-progress attempt to create an XML schema for knitting patterns. What?, I hear you ask. In other words, KnitML is a mark-up language for knitting, along with software to ensure that a pattern is actually knittable and to output the pattern in various human-readable forms. An example would probably be a good thing here, so...

The current version (0.3) of the software can take a pattern like this:

<?xml version="1.0" encoding="UTF-8"?>
<pattern xmlns="http://www.knitml.com/schema/pattern"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.knitml.com/schema/pattern http://www.knitml.com/schema/pattern-0.3.xsd">
<directives>
<message-source>pattern-messages</message-source>
</directives>
<general-information xml:lang="en">
<name>Basic socks</name>
<description>A basic sock pattern with 2x2 ribbing</description>
<dimensions/>
<gauge type="stockinette">
<stitch-gauge unit="st/in">8</stitch-gauge>
<row-gauge unit="row/in">12</row-gauge>
</gauge>
<techniques>
<technique>knitting-in-the-round</technique>
</techniques>
<author>
<first-name>Jonathan</first-name>
<last-name>Whitall</last-name>
</author>
<copyright-info/>
</general-information>
<supplies>
<yarns>
<yarn-type id="lornas-1" brand="Lorna's Laces" category="Shepherd Sock" weight="fingering" catalog-id="33032">
<ball-weight unit="g">50</ball-weight>
<thickness unit="wrap/in">12</thickness>
</yarn-type>
<yarn id="main-color" typeref="lornas-1" message-key="yarn.main-color">
<total-length unit="m">300</total-length>
<total-weight unit="g">100</total-weight>
<color name="watercolor" description="" number="233"/>
</yarn>
</yarns>
<needles>
<needle-type id="size1circ" type="circular" brand="Addi Turbo">
<length unit="in">24</length>
<size unit="US">1</size>
</needle-type>
<needle id="needle1" typeref="size1circ" message-key="needle.needle1"/>
<needle id="needle2" typeref="size1circ" message-key="needle.needle2"/>
</needles>
<accessories/>
</supplies>
<directions>
<instruction-group id="start">
<use-needles>
<needle idref="needle1"/>
</use-needles>
<cast-on style="long-tail">72</cast-on>
<use-needles silent="true">
<needle idref="needle1"/>
<needle idref="needle2"/>
</use-needles>
<arrange-stitches-on-needles>
<needle idref="needle1">36</needle>
<needle idref="needle2">36</needle>
</arrange-stitches-on-needles>
<join-in-round/>
.
.
.
</instruction-group>
</directions>
</pattern>


And turn it into something like this:

Basic socks
A basic sock pattern with 2x2 ribbing
By Jonathan Whitall

Stitch Gauge: 8 st/in
Row Gauge: 12 row/in

Yarn:
100 g (300 m) of Lorna's Laces Shepherd Sock (fingering weight) in watercolor (233)

Needles:
2 circular needles size 1 US (2.25 mm): Addi Turbo, 24 in

Directions
----------
Use Needle 1. Using the long-tail method, cast on 72 stitches.
Arrange stitches as follows:
Needle 1: 36 sts
Needle 2: 36 sts
Join in round, being careful not to twist stitches.

Make the Cuff
-------------
Round 1: Purl
Round 2: *k1, p1, repeat from * to end
Repeat round 2 for 1.5 in.

Knit the Leg
------------
Round 1: *p1, k2, p1, repeat from * to end
Round 2: Knit
Repeat rounds 1-2 until desired length.

Make Heel Flap
--------------
Use Needle 1. Begin knitting flat.
Row 1: *k1, sl 1, repeat from * to 2 sts before end, k2
Row 2: sl 1, p to end
Repeat rows 1-2 17 additional times.

Turn the Heel
-------------
Row 1: sl 1, k19, ssk, k1, turn. 13 unworked stitches.
Row 2: sl 1, p5, p2tog, p1, turn. 13 unworked stitches.

For the next set of rows, you will be decreasing across a small gap. For each row, you will work one additional stitch from the previous row until you are one stitch before the gap. Then you will decrease across the gap and work one more stitch for that row.
Row 3: sl 1, k to 1 st before gap, ssk, k1, turn. 11 unworked stitches.
Row 4: sl 1, p to 1 st before gap, p2tog, p1, turn. 11 unworked stitches.
Repeat rows 3-4 5 additional times.

Row 15: sl 1, k18, ssk
Row 16: sl 1, p18, p2tog
Row 17: sl 1, k9. End of round.

Work Gusset
-----------
Use Needle 1 and Needle 2. Begin knitting-in-the-round.
Arrange stitches as follows:
Needle 1: 28 sts
Needle 2: 28 sts
Round 1:
Needle 1: k10, pick up 18 stitches knitwise, place marker, *p1, k2, p1, repeat from * 4 times, p1, k1
Needle 2: k1, p1, *p1, k2, p1, repeat from * 4 times, place marker, pick up 18 stitches knitwise, k10
Round 2:
Needle 1: k to 3 sts before marker, k2tog, k1
Needle 2: k1, ssk, k to end
Round 3:
Needle 1: k to marker
Needle 2: k to end
Next round:
Needle 1: k to marker, remove marker. End of round.
Arrange stitches as follows:
Needle 2: 36 sts
Needle 1: 36 sts

Make the Foot
-------------
Round 1:
Instep Needle: p1, *k2, p2, repeat from * 8 times, k2, p1
Sole Needle: k to end
Repeat round 1 until desired length.

Make the Toe
------------

Round 1:
Instep Needle: k1, ssk, k to 3 sts before end, k2tog, k1
Sole Needle: k1, ssk, k to 3 sts before end, k2tog, k1
Round 2: Knit

Graft stitches together from Sole Needle and Instep Needle.


However, the same XML could be used to generate patterns in other languages, or even a graphical representation of the pattern. It could also be processed to account for changes in size or gauge. It's all pretty cool IMHO and has a lot of potential. Check out the site linked above if you're interested in learning more!

1 comment:

the fiddlin' fool said...

Just to let you know, we just released Gauge Transformer that allows you to change the pattern gauge. See the KnitML website for details.