xsl-list
[Top] [All Lists]

RE: XML fragment as a param ?

2005-11-03 04:46:10
"Fraser" == Fraser Goffin <goffinf(_at_)hotmail(_dot_)com> writes:

   Fraser> Is it possible to pass in an XML fragment as a param and
   Fraser> then access nodes in the fragment as well as those in the
   Fraser> main source instance ??  For example could I compare a

   Colin> Yes. See the discussion this week.

   Fraser> node value in the original source instance with one in the
   Fraser> fragment passed in as a param ??

   Colin> Yes.

Colin, thanks for the pointer. I assume you mean the technique that was discussed in relation to the document function (note: I am using XSLT 1.0 rather than 2). I tried this (in XML Spy for now), but got the error

'Error in function doument; Could not find external entity'

(see example XSLT below).

Is this perhaps related to to the use of data: not being supported or am I doing something else that is wrong ??

I will be using Xerces/Xalan in the 'real' environment (I know I should use this for testing also), does anyone know whether this technique will work with it/them ??

I haven't come across data: before. I thought that the document() function accepted a resolvable URI as a parameter, so does the use of data: provide a sort of resolver itself then ?

:-

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

 <xsl:param name="inboundXML">
   <xsl:text>default-value</xsl:text>
 </xsl:param>

 <xsl:template match="/">

<!-- try out the suggested technique for passing an XML string to the document function -->

<xsl:variable name="myVar" select="document(concat('data:,text/xml',$inboundXML))"/>

   <!-- output the result -->
   <rootContainer>
       <xsl:value-of select="$inboundXML//Three"/>
   </rootContainer>

 </xsl:template>

</xsl:stylesheet>


XML sent in as param 'inboundXML' :-

<?xml version="1.0" encoding="UTF-8"?>
<Numbers>
 <Odds>
   <One>1</One>
   <Three>3</Three>
   <Five>5</Five>
 </Odds>
 <Evens>
   <Two>2</Two>
   <Four>4</Four>
   <Six>6</Six>
 </Evens>
</Numbers>

Fraser> Is it possible to pass in an XML fragment as a param and then
Fraser> access nodes
Fraser> in the fragment as well as those in the main source instance

Michael>Yes. The way you pass the value depends of course on your processor API.

Michael, not sure what you mean, I'm using Xerces/Xalan if that helps ?

Thanks

Fraser.



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>