RE: [xsl] Retrieve External String XML Data as Object

Subject: RE: [xsl] Retrieve External String XML Data as Object
From: <A.J.Bull@xxxxxxxx>
Date: Wed, 21 Sep 2005 11:28:59 +0200
John, did you ever come up with a solution for this?  I have a similar

In the stylesheet, I can get access to a string that's supposed to be a
node-set.  When I try to convert the string into a node-set, I'm getting what
I think is a flat text-node and I don't know how to fix it.

In the stylesheet, there's a node by the name of "RecipInstituteNum" which
contains the following:


...but as far as I can make out, the stylesheet sees "RecipInstituteNum" as a
text node so that when I try something like:


...I get nothing.  As a work around, I've tried using msxsl:node-set but am
getting a "Cannot convert the operand to 'Result tree fragment'" error and am
having a hard time deciphering Michael's wisdom, so I decided to use msxsl
scripting like below, hoping that the XmlDocument returned would be
intelligible to the stylesheet:

	<msxsl:script language="VB" implements-prefix="user">
		Public Shared Function TransformToNodeset(ByVal arg As String) As
	        Dim reader As XmlTextReader = New XmlTextReader(arg,
XmlNodeType.Document, Nothing)
	        Dim doc As New System.Xml.XmlDocument
	        Return doc
	    End Function

Now, when I try to access RecipInstituteNum like in the following:

	<xsl:value-of select="user:TransformToNodeset(./RecipInstituteNum)"/>

... I get (what I think is) a flat text node:


Any advice?  Thanks!


-----Original Message-----
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Retrieve External String XML Data as Object

You write a URIResolver (under Java JAXP) or XmlResolver (under .NET) that
intercepts the URI and returns an object that the XSLT processor can handle,
for example (under JAXP) a StreamSource wrapping a StringReader that holds
the lexical XML.

Michael Kay

> -----Original Message-----
> From: John [mailto:john-xsl-list@xxxxxxxx]
> Sent: 27 June 2005 21:09
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Retrieve External String XML Data as Object
> I have a data source that is only available through APIs, not through
> URLs or files.  I can represent this external data as XML,
> but how can I
> make this data available to my XSL?  The document() function seems to
> require the first parameter be an URL, and the node-set
> extensions don't
> seem to handle strings (at least not the Microsoft node-set
> extensions).
> Where custom:GetData() basically returns some XML:
> return( "<root><node>some text</node></root>" );
> I have tried:
> <xsl:variable name="extdata" select="msxsl:node-set(
> custom:GetData())" />
> <xsl:value-of select="$extdata/root/node/text()" />
> which gives 'cannot convert the operand to result tree fragment'.
> I have also tried:
> <xsl:variable name="extdata" select="document( custom:GetData())" />
> <xsl:value-of select="$extdata/root/node/text()" />
> Which gives no output.  Do I have to make the data URL-accessible, or
> how can I get this XML into my XSLT as an object instead of a string?
> Should I convert the string to some other type of object before
> returning it to the XSL?  Of course I would prefer to avoid
> extensions
> if possible.  Hopefully there is something like document()
> that works on
> strings instead of URLs?

This email message is intended only for the use of the named recipient.
Information contained in this email message and its attachments may be
privileged, confidential and protected from disclosure. If you are not the
intended recipient, please do not read, copy, use or disclose this
communication to others. Also please notify the sender by replying to this
message and then delete it from your system.

Current Thread