XML Data Source


(Wojciech Bronikowski) #1

Our new project requires a single data-source content approach that would enable the retrival and use of content across different websites on the same Matrix installation as well as being able to offer the source as a web service to remote locations. We opted for XML and begun researching this and looking for the best startegy to achive these goals in Squiz.


What are your thoughts about that?

Is XML Data Source the best solution and what are the performance issues with that? Except Asset Listing, is there any other way to retrieve and print the data that shadow assets point to in XML tree (e.g. using a global keyword)??? We wouldn't want to create an asset listing each time we need to retrieve a telephone number from the XML Data Source.



In other words what would be the Squiz equivalent of Object Oriented PHP and things like traversing/parsing an XML file with PHP and outputting required content as HTML.



The idea is to be able to retrieve required bits of content from the XML data without being limited to asset listing.



Would very much appreciate any ideas you might have.



Wojtek.


(Willh) #2

I've used XML Data Source but have found the implementation difficult. The purpose was to provide a single application for editing staff profiles. The resulting data would be shared amongst systems using XML. The XML Data Source asset picks up the information and uses XSLT to transform it.


The advantages include

  • XSLT allows me to add extra processing to structured information without having to atomise that structure
    [*]Profiles are available to multiple systems without staff having to edit in multiple places

The downsides include
[list][*]the data source asset types retrieve on demand so there is potential latency and load on source systems. Therefore you really have to cache locally
[*]data source assets produce shadow assets which are hard to list in asset listing. The only way that I've found to do it is to add each data source as a root node. Even then, the resulting asset link doesn't show. Proxy assets don't seem to work. I'm not sure what to do besides manual editing.
[*]load is increased on the web server because each time the asset is viewed it retrieves the cached XML and transforms it.
[/list]
It might be worth cacheing and transforming XML, then using the Remote Content asset to present it.

I'd be interested to hear whether anyone else has found a suitable way to work with data source assets.

(Nic Hubbard) #3

We use an XML Data Source asset to gather our Cafe Menu each day. That is when rewritten using an asset listing and it used within our PUC Mobile iOS app. Our XML file isn't huge, so I can't comment on performance issues.


How large is the XML file that you are using? How many records are in the XML? Could you not bring those into Matrix as real assets, such as Data Records? This would give you more flexibility with how you could use them in Matrix. If I were you, and it was at all possible, I would see about getting your data in Matrix as real assets. Then, if you need to offer those as a web service like you mentioned, you can create your own XML listing of those Matrix assets.



I am 99.9% sure that you cannot use global keywords to get any info about shadow assets, Matrix isn't currently built to do that.



Another option, is using jQuery to parse your XML then traverse through it to find what you want. Depending on your XML size this might be a good or bad idea.


(Wojciech Bronikowski) #4

Thanks Nic.


The xml would be quite considerable in size and complexity as we initially planned to have all our product data (accomodation) in a single source distributed across all domains and affiliates - so this would supply at least 70% of the content to the main website. I understand now that most likely we will do as you suggested: bring those assets as real assets and create a convertion method that would allow quick XML creation each time the Data is updated.



I'm guessing that using Data Records implies creating a Metadata Schema to store all the content.

How feasible is it to have most of content of a fairly large website stored as Metadata? Are there any significant performance factors?



It will be fairly easy to create an XML file on the fly from this Metadata Schema so this solution solves some of the problems.



Nevertheless it is a pity that Matrix does not offer any viable way of manipulationg XML files, I was quite happy about the initial results while playing with XML Data Source.


(Nic Hubbard) #5

[quote]
I'm guessing that using Data Records implies creating a Metadata Schema to store all the content.

How feasible is it to have most of content of a fairly large website stored as Metadata? Are there any significant performance factors?

[/quote]



Yes, Data Records are just basic assets that allow you to add metadata to, effectively creating your "own" asset. But, since Metadata values are serialized and stored on the file system, not the database, it is slower. Not sure how much slower though.



Another option is to have a custom asset developed. Then you could store all of your fields that you need in the DB and it would be much faster. I am sure Squiz would be happy to talk with you about custom asset creation.


(Willh) #6

Hi Nic,



how do you convert an XML file into one or more Data Record assets?



thanks

Will


(Nic Hubbard) #7

[quote]
how do you convert an XML file into one or more Data Record assets?

[/quote]



You would need to use the import scripts for this. Specifically the import_from_xml.php might be helpful for you. Checkout the example xml that the manual talks about.



What you will want to do is first use the export_to_xml.php script to get the format for a Data Record asset. Then you can use that to build your xml file which would be imported using import_from_xml.php