This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Re:Re:How to simplify the xslt expression for multiple conditions.
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Re:Re:How to simplify the xslt expression for multiple conditions.
- From: "Yang" <sfyang at unisvr dot net dot tw>
- Date: Mon, 28 May 2001 17:10:41 +0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi, Jeni
> 1. How to pass RTF around to the javascript function?
>I'm sorry - I don't quite get what you're doing here. Are you saying
>that now, rather than passing the name of an XML file into the
>Javascript function, you need to pass some generated XML? If so, you
>need to serialise that XML and escape it to create a valid Javascript
>string.
>Actually I do this in the svg-utils utility - have a look at
>http://www.jenitennison.com/xslt/utilities/svg-utils.xsl for some
>templates that you can use.
Yes, This is exactly what I mean. I try to appy RTF to process output page
by page.
Studying the svg-utils.xsl for a while, I am not quite to reach the
solution and need your to help me out.
As your suggestion, I use two step approach to render the xml file, the
frist one is
to filter out the data based on a set of multiple condition and stored in a
RTF.
Then Using the RTF to diplay the content. Because there are couple of
hundred lines,
I apply Chris Bayes paging example to get the paging capability. During
each paging process,
I try to repeat using RTF, not the original xml file to process the
output. However I can not get
any further and hope you can provide some direction from here.
Thanks in advance.
A list of xsl is listing below fyi.
Sun-fu Yang
sfyang@unisvr.net.tw
*** partial of xsl ****
<!-- from Jeni svg example -->
<xsl:include href="serialiseXML.xsl"/>
<script type="text/javascript">
var DOMXML;
function triggerXMLLoading()
{
<xsl:text>getDOMFromXML('</xsl:text> <=== How to
relate this conversion to the transformload in changePage function?
<xsl:call-template name="serialiseXML">
<xsl:with-param name="originalDoc" select="$originalDoc"/>
</xsl:call-template>
<xsl:text>');</xsl:text>
}
function getDOMFromXML(XML) {
DOMXML = new ActiveXObject('Msxml2.FreeThreadedDOMDocument');
DOMXML.async = false;
DOMXML.validateOnParse = false;
DOMXML.loadXML(XML);
if (DOMXML.parseError.errorCode != 0) {
alert('Error parsing XML:\n' +
explainParseError(DOMXML.parseError));
return;
}
return DOMXML;
}
function
changePage(number,xmlfile,xslfile){ <=== How
can I define xmlfile from a RTF
XMLDOM = new ActiveXObject('Msxml2.FreeThreadedDOMDocument');
XMLDOM.async = false;
XMLDOM.loadXML(xmlfile);
XSLTDOM = new ActiveXObject('Msxml2.FreeThreadedDOMDocument');
XSLTDOM.async = false;
XSLTDOM.load(xslfile);
XSLStylesheet = new ActiveXObject('Msxml2.XSLTemplate');
XSLStylesheet.stylesheet = XSLTDOM;
XSLTProcessor = XSLStylesheet.createProcessor();
XSLTProcessor.input = XMLDOM;
XSLTProcessor.addParameter('pagenumber', number);
XSLTProcessor.transform();
try{
content.innerHTML=XSLTProcessor.output;
}
</script>
..
*** serialiseXML.xsl ***
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="html" />
<xsl:strip-space elements="*" />
<xsl:template name="serialiseXML">
<xsl:param name="originalDoc"/>
<xsl:apply-templates select="$originalDoc" mode="serialise"/>
</xsl:template>
<xsl:template match="*" mode="serialise">
<xsl:text /><<xsl:value-of select="name()" />
<xsl:for-each select="namespace::*[local-name() != 'xml']">
<xsl:if test="not(../../namespace::*[local-name() =
local-name(current()) and . = current()])">
<xsl:text> xmlns</xsl:text>
<xsl:if test="local-name()">:<xsl:value-of select="local-name()"
/></xsl:if>
<xsl:text>="</xsl:text>
<xsl:call-template name="js-escape">
<xsl:with-param name="string" select="." />
</xsl:call-template>
<xsl:text>"</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="@*">
<xsl:text> </xsl:text>
<xsl:value-of select="name()" />="<xsl:text />
<xsl:call-template name="js-escape">
<xsl:with-param name="string" select="." />
</xsl:call-template>
<xsl:text>"</xsl:text>
</xsl:for-each>
<xsl:choose>
<xsl:when test="node()">
<xsl:text />><xsl:apply-templates mode="serialise" />
<xsl:text /></<xsl:value-of select="name()" />><xsl:text />
</xsl:when>
<xsl:otherwise> /></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text()" mode="serialise">
<xsl:call-template name="js-escape">
<xsl:with-param name="string" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template match="comment()" mode="serialise">
<xsl:text><!-- </xsl:text>
<xsl:call-template name="js-escape">
<xsl:with-param name="string" select="." />
</xsl:call-template>
<xsl:text> --></xsl:text>
</xsl:template>
<xsl:template match="processing-instruction()" mode="serialise">
<xsl:text><?</xsl:text>
<xsl:value-of select="name()" />
<xsl:text> </xsl:text>
<xsl:call-template name="js-escape">
<xsl:with-param name="string" select="." />
</xsl:call-template>
<xsl:text> ?></xsl:text>
</xsl:template>
<xsl:template name="js-escape">
<xsl:param name="string" />
<xsl:call-template name="substitute">
<!-- normalize spaces to get rid of line breaks, which javascript does
not like -->
<xsl:with-param name="string" select="normalize-space($string)" />
<xsl:with-param name="find" select='"'"' />
<xsl:with-param name="replace" select='"\'"' />
</xsl:call-template>
</xsl:template>
<xsl:template name="substitute">
<xsl:param name="string" />
<xsl:param name="find" />
<xsl:param name="replace" />
<xsl:choose>
<xsl:when test="$find and $string and contains($string, $find)">
<xsl:value-of select="substring-before($string, $find)" />
<xsl:value-of select="$replace" />
<xsl:call-template name="substitute">
<xsl:with-param name="string" select="substring-after($string,
$find)" />
<xsl:with-param name="find" select="$find" />
<xsl:with-param name="replace" select="$replace" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list