Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - How to sort sequences by scan code? >Thread Next - Re: How to sort sequences by scan code? Re: How to sort sequences by scan code?To: NULL Date: 10/10/2008 11:42:00 AM "Siegfried Heintze" <siegfried@h...> wrote in message news:eRHvSzqKJHA.1308@T...... > I have described a keyboard in XML and I have an XSLT that will produce an > SVG diagram rectangles representing each key of a keyboard with the scan > code centered in the rectangle. > OK, I admit it, it is an ugly keyboard but that is besides the point! > > Now I need to write another XSLT that will emit C++ source code: each > array element will contain the upper left coordinates of the key and width > and the height of the key. The array will be indexed by the scan code. I > cannot figure how how to do this in one shot. > > I think I could do it in two XSLTs. The first XSLT will emit each key as a > single XML element with the scan code as the attribute. Then the second > XSLT will sort by the scan code. Is there a bettery way? > > Thanks, > Siegfried > > > <?xml version="1.0" encoding="utf-8"?> > <generate> > <row id="1"> > <key column="1" x="40" y="40.0" width="12.5" scan-code="1"/> > <key-sequence column-start="2" x-start="59.05" y-start="40" > width="12.5" height="12.5" x-delta="19.05" y-delta="0" repeat="12" > scan-code="59"/> > <key column="14" x="287.65" y="40.0" width="20.7" scan-code="71"/> > <!-- home --> > <key column="15" x="314.90" y="40.0" width="20.725" scan-code="79"/> > <!-- end --> > </row> > <row id="2"> > <key column="1" x="40" y="59.5" width="12.5" scan-code="41"/> > <key-sequence column-start="2" x-start="59.05" y-start="59.5" > width="12.5" height="12.5" x-delta="19.05" y-delta="0" repeat="12" > scan-code="2"/> > <key column="14" x="287.65" y="59.05" width="28.925" scan-code="14" /> > <!-- bksp --> > <key column="15" x="323.12" y="59.05" width="12.5" scan-code="82"/> > <!-- ins --> > </row> > <row id="3"> > <key column="1" x="40" y="78.6" width="20.7" scan-code="124" /> <!-- > tab --> > <key-sequence column-start="2" x-start="66.95" y-start="78.6" > width="12.5" height="12.5" x-delta="19.05" y-delta="0" repeat="12" > scan-code="16"/> > <key column="14" x="295.55" y="78.6" width="20.725" scan-code="43" /> > <!-- bar --> > <key column="15" x="322.82" y="78.6" width="12.5" scan-code="82" /> > <!--ins --> > </row> > <row id="4"> > <key column="1" x="40" y="97.65" width="26.275" scan-code="58" /> <!-- > caps lock --> > <key-sequence column-start="2" x-start="72.82" y-start="97.65" > width="12.5" height="12.5" x-delta="19.05" y-delta="0" repeat="11" > scan-code="30"/> > <key column="14" x="282.37" y="97.65" width="34.12" scan-code="28" /> > <!-- return --> > <key column="15" x="323.12" y="97.65" width="12.5" scan-code="33" /> > <!-- pg up --> > </row> > <row id="5"> > <key column="1" x="40" y="116.70" width="34.2" scan-code="42"/> <!-- > shift --> > <key-sequence column-start="2" x-start="80.75" y-start="116.70" > width="12.5" height="12.5" x-delta="19.05" y-delta="0" repeat="10" > scan-code="44"/> > <key column="12" x="271.25" y="116.70" width="26.275" scan-code="54" > /> <!-- shift --> > <key column="13" x="304.07" y="116.70" width="12.5" scan-code="72" /> > <!-- up --> > <key column="14" x="323.12" y="116.70" width="12.5" scan-code="81" /> > <!-- pg dn --> > </row> > <row id="6"> > <key column="1" x=" 40.00" y="135.75" width="20.7" scan-code="29"/> > <!-- ctrl --> > <key column="2" x=" 67.25" y="135.75" width="20.725" scan-code="91" /> > <!-- flag --> > <key column="3" x=" 94.53" y="135.75" width="20.7" scan-code="18" /> > <!-- alt --> > <key column="4" x="121.78" y="135.75" width="83.125" scan-code="57" /> > <!-- space --> > <key column="5" x="211.46" y="135.75" width="20.7" scan-code="18" /> > <!-- alt --> > <key column="6" x="238.71" y="135.75" width="20.725" scan-code="92"/> > <!-- flag --> > <key column="7" x="265.99" y="135.75" width="12.5" scan-code="93"/> > <!-- ctx --> > <key column="8" x="285.04" y="135.75" width="12.5" scan-code="75" /> > <!-- left --> > <key column="9" x="304.09" y="135.75" width="12.5" scan-code="80" /> > <!-- down --> > <key column="10" x="323.14" y="135.75" width="12.5" scan-code="77" /> > <!-- right --> > > > > </row> > </generate> > > You should just do something like: <xsl:apply-templates select="//key"> <xsl:sort select="scan-code" data-type="number" /> </xsl:apply-templates> <xsl:template match="key"> <!-- create array elements here --> </xsl:template> -- Joe Fawcett (MVP - XML) http://joe.fawcett.name | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
