Discussion:
Error: Expected token 'EOF' found ':'
(too old to reply)
techie
2006-01-14 22:02:24 UTC
Permalink
I'm trying to apply a XSLT transformation on a XML file. The XSLT file
takes as parameter another XML file (node set). It actually merges the two
XML files.

I load the first XML file into a DOMDocument object (pXmlDoc), followed by
the XSLT (pXslDoc). Then I set the parameter in the XSLT document by
setting the text of the param node. The text is

document('C:\TEMP\GAZ193.tmp')

I create a new DOMDocument for the output and wrap it in a VARIANT:

VARIANT v;
v.vt = VT_DISPATCH;
v.pdispVal = oOutput;

As soon as I do the transformation below,

pXmlDoc->transformNodeToObject( pXslDoc, v );

I get a COM exception:

"Expected token 'EOF' found ':'.

C-->:<--\TEMP\GAZ193.tmp"

Any idea what could be the cause of this error? Could it be anything to do
with namespaces?
Janwillem Borleffs
2006-01-15 01:53:32 UTC
Permalink
Post by techie
"Expected token 'EOF' found ':'.
C-->:<--\TEMP\GAZ193.tmp"
Any idea what could be the cause of this error? Could it be anything
to do with namespaces?
I believe that when using absolute URIs, you should use the file protocol,
e.g.:

file:///C:/TEMP/GAZ193.tmp


JW
techie
2006-01-15 06:17:18 UTC
Permalink
Post by Janwillem Borleffs
Post by techie
"Expected token 'EOF' found ':'.
C-->:<--\TEMP\GAZ193.tmp"
Any idea what could be the cause of this error? Could it be anything
to do with namespaces?
I believe that when using absolute URIs, you should use the file protocol,
file:///C:/TEMP/GAZ193.tmp
I tried the file protocol but still get the same error.
AnthonyWJones
2006-01-15 08:35:02 UTC
Permalink
You said:-

'Then I set the parameter in the XSLT document by
setting the text of the param node.'

Can you show us more explicitly how you do that. I think that is where the
problem is.

Anthony.
Post by techie
Post by Janwillem Borleffs
Post by techie
"Expected token 'EOF' found ':'.
C-->:<--\TEMP\GAZ193.tmp"
Any idea what could be the cause of this error? Could it be anything
to do with namespaces?
I believe that when using absolute URIs, you should use the file protocol,
file:///C:/TEMP/GAZ193.tmp
I tried the file protocol but still get the same error.
techie
2006-01-15 09:19:07 UTC
Permalink
Here's my code (it's VC++):

//Select the param node
MSXML2::IXMLDOMNodePtr pXSLNode;
CString param;
param.Format("document('file:///%s')", m_IndexFile);
MSXML2::IXMLDOMElementPtr root = pXslDoc->documentElement;
CString Namespace;
_variant_t vt = root->getAttribute("xmlns:xsl");
Namespace.Format("xmlns:xsl='%s'", CString(vt.bstrVal) );
pXslDoc->setProperty(_bstr_t("SelectionNamespaces"), _bstr_t(Namespace));
pXSLNode =
pXslDoc->selectSingleNode(_bstr_t("//xsl:param[@name='ndsDailyDocument']"));
if (pXSLNode == NULL)
{
m_sError = "Unable to select 'param' node in Merge XSLT";
pXslDoc.Release();
oOutput.Release();
return FALSE;
}
else
{
//Set text of param 'select' attribute
MSXML2::IXMLDOMNodePtr pParam =
pXSLNode->attributes->getNamedItem("select");
pParam->text = _bstr_t(m_IndexFile);
}

VARIANT v;
v.vt = VT_DISPATCH;
v.pdispVal = oOutput;

pXmlDoc->transformNodeToObject( pXslDoc, v );


I am selecting the param node with @name='ndsDailyDocument' and setting the
text. Everything seems to work OK until transformNodeToObject.

This is the param node in the XSLT:

<xsl:param name="ndsDailyDocument"
select="document('c:\temp\intermediate.xml')"/>

I am actually replacing the select attribute to the actual value.

Just looking at top of the XML file I send to the XSLT parameter I find:

<Index xsi:schemaLocation="http://www....index c:/index/schema.xsd"
SchemaVersion="1.0" xmlns="http://www....index"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcq="http://purl.org/dc/terms/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

I don't have a c:\index folder. Is that a problem?
Joe Fawcett
2006-01-15 10:49:30 UTC
Permalink
Post by techie
//Select the param node
MSXML2::IXMLDOMNodePtr pXSLNode;
CString param;
param.Format("document('file:///%s')", m_IndexFile);
MSXML2::IXMLDOMElementPtr root = pXslDoc->documentElement;
CString Namespace;
_variant_t vt = root->getAttribute("xmlns:xsl");
Namespace.Format("xmlns:xsl='%s'", CString(vt.bstrVal) );
pXslDoc->setProperty(_bstr_t("SelectionNamespaces"), _bstr_t(Namespace));
pXSLNode =
if (pXSLNode == NULL)
{
m_sError = "Unable to select 'param' node in Merge XSLT";
pXslDoc.Release();
oOutput.Release();
return FALSE;
}
else
{
//Set text of param 'select' attribute
MSXML2::IXMLDOMNodePtr pParam =
pXSLNode->attributes->getNamedItem("select");
pParam->text = _bstr_t(m_IndexFile);
}
VARIANT v;
v.vt = VT_DISPATCH;
v.pdispVal = oOutput;
pXmlDoc->transformNodeToObject( pXslDoc, v );
text. Everything seems to work OK until transformNodeToObject.
<xsl:param name="ndsDailyDocument"
select="document('c:\temp\intermediate.xml')"/>
I am actually replacing the select attribute to the actual value.
<Index xsi:schemaLocation="http://www....index c:/index/schema.xsd"
SchemaVersion="1.0" xmlns="http://www....index"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcq="http://purl.org/dc/terms/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
I don't have a c:\index folder. Is that a problem?
Try saving the file after you've made the modifications, does the URI use /
rather than \?
--
Joe Fawcett - XML MVP

https://mvp.support.microsoft.com/profile=8AA9D5F5-E1C2-44C7-BCE8-8741D22D17A5
techie
2006-01-15 11:38:01 UTC
Permalink
Post by Joe Fawcett
Try saving the file after you've made the modifications, does the URI use /
rather than \?
Thanks for the suggestion. Saving the file to disk showed that I wasn't
setting the select attribute of param properly. It was 'C:/TEMP/GAZ193.tmp'
instead of document('file:///C:/TEMP/GAZ193.tmp').

There was bug in my code:

param.Format("document('file:///%s')", m_IndexFile);
..
..
pParam->text = _bstr_t(m_IndexFile);


It should have been

pParam->text = _bstr_t(param);

Silly mistake. Now its working!
Joe Fawcett
2006-01-19 17:46:13 UTC
Permalink
Post by techie
Post by Joe Fawcett
Try saving the file after you've made the modifications, does the URI use
/
Post by Joe Fawcett
rather than \?
Thanks for the suggestion. Saving the file to disk showed that I wasn't
setting the select attribute of param properly. It was
'C:/TEMP/GAZ193.tmp'
instead of document('file:///C:/TEMP/GAZ193.tmp').
param.Format("document('file:///%s')", m_IndexFile);
..
..
pParam->text = _bstr_t(m_IndexFile);
It should have been
pParam->text = _bstr_t(param);
Silly mistake. Now its working!
Ah, I see your passing in the whole string, "document£ and all, I would just
pass the name of the file and have the document function separate.
--
Joe Fawcett - XML MVP

https://mvp.support.microsoft.com/profile=8AA9D5F5-E1C2-44C7-BCE8-8741D22D17A5
Joe Fawcett
2006-01-15 10:16:29 UTC
Permalink
Post by techie
I'm trying to apply a XSLT transformation on a XML file. The XSLT file
takes as parameter another XML file (node set). It actually merges the two
XML files.
I load the first XML file into a DOMDocument object (pXmlDoc), followed by
the XSLT (pXslDoc). Then I set the parameter in the XSLT document by
setting the text of the param node. The text is
document('C:\TEMP\GAZ193.tmp')
VARIANT v;
v.vt = VT_DISPATCH;
v.pdispVal = oOutput;
As soon as I do the transformation below,
pXmlDoc->transformNodeToObject( pXslDoc, v );
"Expected token 'EOF' found ':'.
C-->:<--\TEMP\GAZ193.tmp"
Any idea what could be the cause of this error? Could it be anything to do
with namespaces?
Which parser are you using?
Technically you haven't supplied a valid document location although some
parsers are more forgiving than others.
Try:

document('file:///C:/temp/gaz193.tmp')
--
Joe Fawcett - XML MVP

https://mvp.support.microsoft.com/profile=8AA9D5F5-E1C2-44C7-BCE8-8741D22D17A5
Martin Honnen
2006-01-15 12:59:22 UTC
Permalink
Post by techie
I'm trying to apply a XSLT transformation on a XML file. The XSLT file
takes as parameter another XML file (node set). It actually merges the two
XML files.
I load the first XML file into a DOMDocument object (pXmlDoc), followed by
the XSLT (pXslDoc). Then I set the parameter in the XSLT document by
setting the text of the param node. The text is
document('C:\TEMP\GAZ193.tmp')
If needed you can go that approach with MSXML to manipulate the DOM of a
stylesheet but as already suggested the document function in XSLT
expects a URI and a local file URI will look alike
document('file:///C:/TEMP/GAZ193.tmp')

There are other (and maybe better) ways however to set parameters, there
is an API for that, see
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/9ddcd728-2646-494a-8fa4-3b68e8c032b7.asp>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Loading...