[4suite-dev] Simple Xlink processing - is it possible with 4Suite?
Sidney
csidney79 at gmail.com
Sun Nov 18 09:39:53 MST 2007
Take a look at the code for the XLink processor (Ft/Xml/XLink/Processor.py).
You will see that it's only method takes an input source. See
Ft/Xml/InputSource.py.
So if your XML file is on a remote server or file system, you will need to
do something like this:
from Ft.Xml.InputSource import DefaultFactory
from Ft.Xml.XLink.Processor import Processor
sourceUri = 'file:///var/local/data/xml/myfile.xml'
# if file is on a remote HTTP server, use something like:
# sourceUri = 'http://www.myserver.com/data/myfile.xml'
iSrc = DefaultFactory.fromUri(sourceUri)
xlinkProc = Processor()
domDoc = xlinkProc.run(iSrc)
# domDoc is your document with your XLinks resolved and expanded accordingly
to the rules of XLinks. Take a look at Ft/Xml/XLink/XLinkElements.py for
details.
#########
If you store your XML file somewhere different other then a file or a remote
HTTP server, you can also pass in a string. For example:
sourceString = myCustomReadFileToString()
iSrc = DefaultFactory.fromString(sourceString, 'urn:uuid:my_fake_uri')
###########
Again take a look at the respective library source code if you need a
solution more tailored to your needs.
Best of luck!
P.S. Your question would be better served sent to the 4suite general list.
-----Original Message-----
From: 4suite-dev-bounces at lists.fourthought.com
[mailto:4suite-dev-bounces at lists.fourthought.com] On Behalf Of
timjones at nhs.net
Sent: Monday, October 15, 2007 4:07 PM
To: 4suite-dev at lists.fourthought.com
Subject: [4suite-dev] Simple Xlink processing - is it possible with 4Suite?
Guys - a pointer please.
I have thousands of xml files with elements like:
<ElementLink xlink:type="simple" xlink:href="another.xml" xlink:title="the
title"/>
I need to drill through to the linked document with an xpath.
I can do this with an xquery in Stylus studio with an xquery like:
doc(//ElementLink/@xlink:href)//SAProperty/@SAPrpValue
Can't see anything at all in the 4-Suite documentation, although the
overviews say that xlink is supported.
There seems to be something hopeful at
http://infinitesque.net/projects/4Suite/docs/modules/Ft.Xml.XLink.Processor.
html
No helpful documentation here however.
Can anyone help with a simple example or an alternative approach (in
python)?
(pyexpat just falls over complaining about the xlink namespace)
Regards,
Tim
**********************************************************************
This message may contain confidential and privileged information.
If you are not the intended recipient please accept our apologies.
Please do not disclose, copy or distribute information in this e-mail
or take any action in reliance on its contents: to do so is strictly
prohibited and may be unlawful. Please inform us that this message has
gone astray before deleting it. Thank you for your co-operation.
NHSmail is used daily by over 100,000 staff in the NHS. Over a million
messages are sent every day by the system. To find out why more and
more NHS personnel are switching to this NHS Connecting for Health
system please visit www.connectingforhealth.nhs.uk/nhsmail
**********************************************************************
_______________________________________________
4suite-dev mailing list
4suite-dev at lists.fourthought.com
http://lists.fourthought.com/mailman/listinfo/4suite-dev
More information about the 4suite-dev
mailing list