The XML documents I get delivered and may not touch them, as they must be
passed on further.
The XSL transform I have functioning, and when I run it against any of my
source XML documents using the Java Saxon engine, it works just great, gives
me exactly the output I need. (It also uses a CSS stylesheet.)
The problem is that the result of the transform needs some slight manual
touching up. The transform creates an output file, which is nicely displayed
by either Word or a browser. When I run the transform again, while
displaying the file in a browser, a simple refresh is enough to show the new
results. But when I have the output file open in Word, the transform
crashes, since it cannot overwrite a file that Word is using.
I would like to be able to open the source XML file in Word and have the XSL
transform run against it as it opens, so that the user sees directly the
results of the transform and can further manipulate the resulting document.
I am fairly skilled in VBA and have spent quite a bit of time experimenting
with things like
Set objSchema = Application.XMLNamespaces(1)
Set objTransform = objSchema.XSLTransforms.Add("C:\Saxon\RIV2009.xsl")
and
Application.XMLNamespaces.Item(1).AttachToDocument Document:=ActiveDocument
and such, but have not managed to put together all the pieces to make this
work as I need. For instance, when I manually add the transform and try to
show the results, I get no output, despite the transform working perfectly
with Saxon. None of my coding attempts have produced anything workable and
many of them crash Word.
Is this even possible? Does the transform engine in Word work correctly? Do
I need to do something special in the transform to make it acceptable to
Word?
I can modify the transform however needed but, again, I cannot touch the
contents of the XML source files.
Pete
--
This e-mail address is fake, to keep spammers and their address harvesters
out of my hair. If you want to get in touch personally, I am 'pdanes' and I
use yahoo mail. But please use the newsgroup when possible, so that all may
benefit from the exchange of ideas.
just a hint..
try the Field INCLUDETEXT
it allows the insertion of an external xml-file through a transformation.
Sample:
{ INCLUDETEXT "D:\\office xml\\Winword2003 MemoSample\\Plain
MemoTest1.xml" \t "D:\\office xml\\Winword2003 MemoSample\\Memo.xsdPlain
Memo.pur.xml.XSLT" \* MERGEFORMAT }
in Word XSLTs are treated like other external code. Security must be set to
allow transformations.
The transformation result is constructed in some tmp-folder, external
references maybe not working as expected.
willib
"Skru spammers" <skrusp...@no.spam> schrieb im Newsbeitrag
news:OBFe0rJZ...@TK2MSFTNGP06.phx.gbl...
However, I've given it a try and even the documentation says that it should
work, but all I've gotten for output so far is "Error!" or sometimes "Error
reading file!". No explanation, no error message number. I've scanned all
sorts of NG archives and not found anything useful. Any ideas on where I
might start looking? Again, this is an XML source and XSL transform that
work perfectly under Saxon.
Pete
"willib" <wil...@NOSPAMAbreitwieser.net> p�se v diskusn�m pr�spevku
news:OZ5hpoR...@TK2MSFTNGP05.phx.gbl...
> However, I've given it a try and even the documentation says that it should
> work, but all I've gotten for output so far is "Error!" or sometimes "Error
> reading file!". No explanation, no error message number. I've scanned all
> sorts of NG archives and not found anything useful. Any ideas on where I
> might start looking? Again, this is an XML source and XSL transform that
> work perfectly under Saxon.
Which version of Saxon is that, which XSLT version do you use in the
stylesheet? Saxon 9 is an XSLT 2.0 processor while Microsoft does not
have any XSLT 2.0 implementation, it only supports XSLT 1.0.
--
Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/
The transform contains
<xsl:transform version="2.0"...
but I tried changing it to
<xsl:transform version="1.0"...
and no change, except Saxon warns me that I'm
"Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor"
But it still works and Word still doesn't.
Pete
Thanks for the advice, I can take it from here.
Pete
"Martin Honnen" <maho...@yahoo.de> p�se v diskusn�m pr�spevku
news:OXFfSBiZ...@TK2MSFTNGP04.phx.gbl...
As you want to use XSLT 2.0 from within Word or VBA you might also
consider AltovaXML tools instead of Saxon. It is a COM based solution
you can script with VB(A), contrary to Saxon.
See http://www.altova.com/altovaxml.html
Pete
"Martin Honnen" <maho...@yahoo.de> p�se v diskusn�m pr�spevku
news:O3xuJKtZ...@TK2MSFTNGP05.phx.gbl...
Just a follow-up - that did it. The documentation takes a bit of pondering,
but it's not too bad. I finally had to go around three sides of a block: I
don't want the the resulting file opened in Word, since that precludes
overwriting it, unless the user first closes it, before running my code.
Then I tried IncludeFile, but that munches my CSS/HTML formatting. So I
create the output into a file, open the file as an invisible document, copy
the text from there, do a "PasteAndFormat wdFormatOriginalFormatting" to
preserve the look and close the invisible document, so that the file is
released for another (over)write process.
A bit clunky, but works like charm and the entire routine is less than 20
lines of VBA code.
Many thanks, you've saved me a tremendous amount of fruitless experimenting.
Pete
"Martin Honnen" <maho...@yahoo.de> p�se v diskusn�m pr�spevku
news:O3xuJKtZ...@TK2MSFTNGP05.phx.gbl...