Jump to content

Schema in a third party application


rbennett

Recommended Posts

I had a 50-50 shot of asking this under basic XML questions forum or specifically in the Schema section...I'm basically a php guy and the XML is a new avenue for me - I'm doing some research into xml for a project to provide data to a third party in which they will write their own application.I've gotten past the initial build/delivery of the XML file itself, I did a simple test early on and they provided a link to their schema for this purpose. My question is: generally, in a situation where I'm providing the data and they are providing the application to interpret and run it, would the client always provide their own schema? if I use this same data for other clients should I have a in-house schema to distribute? or they would always design their own for their program?(sorry I'm just having a little problem grasping this)thanks!

Link to comment
Share on other sites

The author of the XML language should be the one to create the Schema. You're otherwise missing the point of it.XML Schema describes what is valid in a document and allows IDEs to be intelligent in what they allow the users to do.Instead of telling your clients "For this to work, use this and that element with this attribute on that element", you'll be describing all of it in a schema. The clients should then use that schema to validate what they have and execute their application only if all is OK.If they were making their own schemas, the point is lost, as then they are using their own set of rules, rather then following yours.And as a side note, if you accept input XMLs for your own application from unknown parties, the XML being used for the application to do something, you should use your own schema to validate the input, as your application may otherwise do something majorly wrong like getting out of memory, crashing the server, etc. etc. etc. In other words, validating XML input with a schema is just as important as is validating POST variables with PHP.

Link to comment
Share on other sites

Good answer. I would add.Note the Schema defines "the grammar" of the document. An xml document must be well-formed, bud need not validate, that is, conform to its schema.In my view, XML Schema is of utmost importance, especially for large companies since that will get a very strict control over their documents.<digression>Note there is a document function, that can be used in XSLT style sheets for accessing multiple documents from within one style sheet. It is an XSLT extension of XPath.</digression>

Link to comment
Share on other sites

Thanks two both of the replys.That gives me a different perspective. Perhaps I'm not the true "author" of the xml after all. The client had provided me with Names for the XML tags and what they wanted to use as their "headers" etc. I wrote the code to linkup to my DB and output my data (in my file) using their tag names... and delivered the resulting XML file back to them. I was doing a little more research into xml, reading about the schema and it dawned on me that they never requested a schema - I was viewing my resulting file as a document that may need a schema but... they originally dictated what the tag names should be, so maybe they have everything on their end that they need.Anyway The original question presented itself while wondering what I needed to do to deliver my data to other clients using this same method ?I won't hold you guys up any more. I appreciate your time and admittedly I need to learn more about XML (but I'll happily read any other comments you may have).Thanks!

Link to comment
Share on other sites

Anyway The original question presented itself while wondering what I needed to do to deliver my data to other clients using this same method ?
If by "method" you mean "resulting XML", then what you need to do is keep the schema from the one that gave it to you and use a special schema aware editor to create new files of this format (after which you'll of course validate the file against that same schema).One good editor for that is Stylus Studio. If you create an XML document and associate it with a schema, the XML editor will only show you auto complete options for elements and attributes as they are allowed. You'll of course be allowed to enter anything if you don't follow the schema provided. There's a schema validation button that will validate the XML against the associated schema(s) or against a specific one, not associated with the document.If you don't want to get such an editor, you should at least create manually your files and validate them with PHP, and with the DOMDocument::schemaValidate() to be more precise. To see the exact error messages from it, use the libxml functions.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...