[wpkg-users] [Bug 3] fix to split packages.xml into smaller files

bugzilla-daemon at wpkg.org bugzilla-daemon at wpkg.org
Mon May 8 19:54:58 CEST 2006


Please reply using this URL only: http://bugs.wpkg.org/show_bug.cgi?id=3





------- Additional Comments From snakebyte at email.dk  2006-05-08 19:54 -------
i have tried to download a clean version of wpkg 0.9.8
and the only thing i changed was the following:

NB: it is important to remove the old loadxml function....

if you can't make it work please send me some examples of your xml files i can
test it with.

if i remember correctly i included some of mine the last time i uploaded this
fix. if not i will gladly send you some ??


/*-------------------------------code changed
start------------------------------------*/
    // load packages and profiles
	hosts = loadXml( hosts_file, createXsl( base, "hosts" ) );
	profiles = loadXml( profiles_file, createXsl( base, "profiles" ) );
	packages = loadXml( packages_file, createXsl( base, "packages" ) );
/*-------------------------------code changed
end------------------------------------*/



/*-------------------------------code changed
start------------------------------------*/

/**
 * Loads an XML file and returns the root element.
 */
function loadXml( xmlPath, xslPath ) {
	var source = new ActiveXObject("Msxml2.DOMDocument.3.0");
	source.async = false;
	source.validateOnParse = false;
	source.load( xmlPath );
	
	if (source.parseError.errorCode != 0) {
	   var myErr = source.parseError;
	   info( "Error parsing xml: " + myErr.reason );
	}
	else {
		if( xslPath != null ) {
			var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0")
			xmlDoc.async="false"
			xmlDoc.validateOnParse = false;
			xmlDoc.loadXML( source.transformNode( xslPath ) );
			return xmlDoc.documentElement;
		}
		else {
			return source.documentElement;
		}
	}
}

/**
 * Creates xsl document object and returns it.
 */
function createXsl( base, folder ) {
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	var file;
	if( !fso.folderExists( base + "\\" + folder ) ) {
		return null;
	}
	var e = new Enumerator(fso.GetFolder( base + "\\" + folder ).files);
	var str = "";
	var root = "";
	if( folder == "hosts" ) {
		root = "wpkg";
	}
	else {
		root = folder;
	}
	str = "<?xml version=\"1.0\"?>\r\n";
	str = str + "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"
version=\"1.0\">\r\n";
	str = str + "	<xsl:output encoding=\"ISO-8859-1\" indent=\"yes\" method=\"xml\"
version=\"1.0\"/>\r\n";
	str = str + "	<xsl:template match=\"/\">\r\n";
	str = str + "		<" + root + ">\r\n";
	str = str + "			<xsl:copy-of select=\""+ folder + "/child::*\"/>\r\n";
	for( e.moveFirst(); ! e.atEnd(); e.moveNext() ) {
		file = e.item();
		str = str + "			<xsl:copy-of select=\"document('" + base.replace( /\\/g, "/" )
+ "/" + folder + "/" + file.name + "')/" + root + "/child::*\"/>\r\n";
	}
	str = str + "		</" + root + ">\r\n";
	str = str + "	</xsl:template>\r\n";
	str = str + "</xsl:stylesheet>\r\n";
	var xsl = new ActiveXObject( "Msxml2.DOMDocument.3.0" );
	xsl.async = false;
	xsl.loadXML( str );
	return xsl.documentElement;
}

/*-------------------------------code changed
end------------------------------------*/


-- 
Configure bugmail: http://bugs.wpkg.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.







_______________________________________________
wpkg-users mailing list
wpkg-users at lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/wpkg-users




More information about the wpkg-users mailing list