Need help with Golfml2SVG XSL transform

18 views
Skip to first unread message

j1medea

unread,
Nov 30, 2010, 3:25:28 PM11/30/10
to Golf Markup Language
HI All,

I just discovered GolfML and I think its very handy. I am looking to
create a a scorecard of my home course. So far I was able to create a
KML file and transform it to XML with a firefox plugin and now am
stuck on transforming the courses GolfML to SVG.

What are the best tools for transforming XML with the Golfml2SVG.xsl
stylesheet. I am able to load the GolfML XML on my XAMPP witch is
running on windows vista with no problem but when I try to add a link
to the golfml2svg.xsl atop the newly created Golf Course XML I get
XSLT errors in my browsers.

The first error I get is with the XPath engine it tells me that it is
calling an undefined function " min() , It appears the functions
min(../@lat) and max(../@lat) do not work with XSLT 2.0. Once I change
the version of the golfml stylesheet to 1.0 the error goes away and a
new error appears now the error says "Error: xsl:output/@name:
invalid attribute"

I have tried to load in Firefox, Opera, IE, and safari.

Firefox stops script about half ways through, and in Safari it loads a
builds the stylesheet buit then returns "N" at the end. Not sure if it
had to do with the wrapped CDATA.

Any Ideas or help with transformation tools will be greatly
appreciated.

Thanks,

Jason

I must admit XSLT transformations are not my cup of tea but I have
added XSL sheets to XML with no problems before. I work mainly with
XHTML,CSS, JS and PHP. I am thinking this should all be done on a java
server.


j1medea

unread,
Dec 3, 2010, 3:20:03 PM12/3/10
to Golf Markup Language
I am making progress but still am having a lot of different errors
depending on how I try to render the golfml2svg.

When I try to run it through firefox I get errors when calling MATH
functions. When I try in Opera and Safari, I get it to spit out the
CSS from the golfml2svg, In IE I get namespace errors.

I made some progress when I viewed it on a java platform by startingup
the microemulator and running OperaMini in it. When I use Opera mini I
can see the calculations being done and when it renders it shows only
a text version of all the placemarks but does not transform it to SVG
and I have tested svg in all my browsers. I can view all SGV files in
all my browsers so I know I have SVG support. I Get the same issue
with it transforming to text when I view in the iphone safari browser.
It seems that viewing via mobile browser MATH functions are
calculated.

I have also installed Batik and attempted to view the xml file in
squiggle, but it tells me squiggle does not support SVG 0.9.

Lastly I have installed SaxonHE9, Saxon is installed and also has the
PATH set. I get the same errors as I do when I run in regular browsers
as I do from the command line. I have tried to run from the command
line using, java -jar saxonhe9.jar Transform -s:jgjhgjhagsd -
xsl:kjhkhsadkh -o:c:\filename.svg but I still get the same MATH
errors.

I have it installed as the path so at the command line I can also try
and transform by just typing ( Transform -s:jgjhgjhagsd -
xsl:kjhkhsadkh -o:c:\filename.svg ) I have tried everything even with
net.sf.saxon.Transform.

Finally, I found a site that transforms kml2svg so after creating a
course I just run it through the website and it comes out with the
default google earth stylings. It's not as nice looking so I would
like to figure this out.

I have XP, Vista, Linux Ubuntu and a Mac at home, Maybe I should be on
a mac or linux ...... Whats the trick I needs some help.

j1medea

unread,
Dec 6, 2010, 5:19:59 PM12/6/10
to Golf Markup Language
OK now that was fun. Well I ended up installing the simple to use
Editix-XML Editor. This editor makes working with golfml XML and XSL
files very simple, it also has a simple transform tool for converting
klm to xml and xml to svg or any other xml format.

Anyways, I found out what was causing all these errors when
transforming the golfml2svg. It turns out that when I save my google
earth place as KML it throws a empty line for <position><gps lat=""
lon=""/> at the end of every placemark. It also generates a white
space at the first line positions #1 so basically a polygon would have
the coodinates messed up on the first line and the last would be
empty. What was weird was that because the first line had a space in
it the KML2golfml would out put the first lat coordinate as and
Encoded string. I am not sure if it is Google Earth that is Malformed
or just the output from the kml2golfml conversion.

<aoi type="hole-contour">
<name>hole 15 contour</name>
<description/>
<position number="1">
<gps
lon="&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;-121.3413512156024"
lat="38.00632405040819" alt="0"/>
</position>
<position number="2">
<gps lon="-121.3414357884927"
lat="38.00609234182868" alt="0"/>
</position>
<position number="3">
<gps lon="-121.3413323262345"
lat="38.00606082739143" alt="0"/>
</position>
....................
....................
....................
<position number="34">
<gps lon="-121.3413512156024"
lat="38.00632405040819" alt="0"/>
</position>
<position number="35">
<gps lon="" lat="" alt=""/>
</position>
</aoi>


The fix was to find a quick way to fix both errors, What I did to
convert all instances of the lat coordinate in position 1 was just to
use Editix to apply the Pretty Style Formating, That would convert all
encoded lat strings to a numeric value. What you were left with was
position 1 with about 5 tabs of space. Removed the space using find
and replace in dreamweaver, Also used dreamweaver to find and replace
all instances of the empty <position number="35"><gps lon="" lat=""
alt=""/> the trick here was to dynamically find all empty position
numbers with a regex expression like so ( <position number=" [^']*
"<gps lon="" lat="" alt=""/>

Anyways some cool code thanks for hosting on google. Be back to chat
after I figure out what i want to use it for besides making my local
course.

I do have one recommendation and that would be to also make the
dynamic distance script touchable for touch devices. I was hacking
around in the SVG and added a draggable element using iphones
ontouchmove and ontouchstart but when I would apply it to target I
could not get it to drag/move.


Thanks, Jason
Reply all
Reply to author
Forward
0 new messages