Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting XML using XSL loading the xml string



Hello Mark,

it would be great to know how sortXML(xmlDoc) is called.
What type is xmlDoc ?
If it is just an URL it fails.
To load an XML file you will need something like Apple provides at "http://developer.apple.com/internet/webcontent/xmlhttpreq.html";.
Anyway the variables xml and xsl do not know the method .load().


since apple provides only an asynchronous exsample, which might be not easy to handle, you may want to try this :

function loadXLM( url ) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", url, false);
xmlHttp.send(null);

if (xmlHttp.readyState == 4) {
//the following if statement only works if the URL really points to a WebServer
//if (xmlHttp.status == 200) {
return xmlHttp.responseXML;
//}
}
}


Hope that helps.

Michael



I am queirying a server and getting a returned xml string within in a soap wrapper. I have done some searching and found that I can then sort the data using and XSL style sheet.

My problem is this, I am trying to load both my xml string and then the xsl string and do the transformNode then return the sorted xml and display it in my widget.

I keep getting the undefined value _javascript_ error about my loaded xml string. Here is the code:

=======================
I pass in the xml string and the debug displays it fine.

function sortXML(xmlDoc){

	DEBUG("the passed xml is " + xmlDoc);
	var myXSLtemplate = "<<?xml version='1.0'?>\n\
<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/TR/WD-xsl\";>\n\
<xsl:template match=\"/\">\n\
    <table border=\"2\" bgcolor=\"yellow\">\n\
      <tr>\n\
        <th>Title<\/th>\n\
        <th>Artist<\/th>\n\
      <\/tr>\n\
      <xsl:for-each select=\"CATALOG/CD\" order-by=\"+ ARTIST\">\n\
      <tr>\n\
        <td><xsl:value-of select=\"TITLE\"/><\/td>\n\
        <td><xsl:value-of select=\"ARTIST\"/><\/td>\n\
      <\/tr>\n\
      <\/xsl:for-each>\n\
    <\/table>\n\
<\/xsl:template>\n\
<\/xsl:stylesheet>";

// Load XML
var xml;
xml.load(xmlDoc); HERE IS WHERE THE _javascript_ ERRORS "undefined value"


// Load the XSL
var xsl;
xsl.load(myXSLtemplate);

// Transform
var sortedXML = xml.transformNode(xsl);

return sortedXML;


} ======================

Any help is appreciated.

Mark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.