stratos last edited by
I'm currently researching what to use for a project.
The basic task is to be able to define in a simple way the following things:
grouping of blocks (linking multiple blocks too eachother)
defining validation schemes for blocks (email validation, string matching, etc...)
defining behaviour for blocks (text align types, img fitting types)
defining behaviour for groups of blocks. (float elements up)
if then else structure. (if empty:block_01 :: hide:block_02)
defining type of input for blocks. (text/enum/etc..)
It's for a CMS system that defines custom template pages that can be filled in by others.
So for instance you could have a contact page that has the following attributes.
Now the structure of the page can allready be defined by a existing system in a XML. However now we want to be able to make the dynamic elements be controlable by logic. For instance, if no "mob" is filled in by a user, "fax" should move up to the place where mob used to be. Also the value in tel and mob should be validated to a telephone nummber.
Now i think this reeks XSLT + XML scema/relaxNG, however i'm worried i won't be able to express al the requirements into this. ideally i would want something where i could define it all in 1 structure.
For instance take the following mock XML'ish definition.
<element name="contact_block" type="groupmacro">
<element name="tel_block" type="groupmacro">
<element name="block_text_tel" />
<element name="mob_block" type="groupmacro">
<element name="block_text_mob" />
<element name="fax_block" type="groupmacro">
<element name="block_text_fax" />
Now the kicker is that while it will initially be used to generate html document, in the future it should be able to also create other output types. Because of this the system should not assume that common HTML behaviour will occur. (like elements automatically floating up, because the item above it doesnt have any text)
I'm currently reading into XSLT and XML schema, since i only have a very shallow understanding of those standards. But i was hoping someone here might have had experience with this kind of stuff, and could tell me if i'm even looking in the right direction.
PSWorx last edited by
I think as a basic principle you can say, XSLT/Scheme is the tool of choice if you need to manipulate XML data - that is the hierarchy of nodes and attributes and so on. On the other hand, XSLT completely fails at processing non-XML data (like e-mail adresses). It is possible but unnecessarily painful and complicated.
So I'd say, if your input data already is in a clearly-structured "true" XML format and if you think you can use most of the actual text content inside (text elements, attribute values) directly, without further processing or validating, go for XSLT.
However, if you have non-XML strings or a WTF application with "pseudo XML" a la "<data>some huge string in csv or a custom format</data>" go for regexes instead.
If you want to use XSLT client-side, keep in mind too that there are still many browsers that haven't implemented it yet. So if you're programming for the 'net, you want to provide fallbacks.
If you want to use it server-side you might also want to take a look at XQuery, a similar technology that could be easier to use.
masklinn last edited by
Word of the wise: if you want XML data specification, do NOT use XML Schemas.
They're verbose, annoying, and they will trip you time and time again, plus if you ever try to handle multiple namespaces you're hosed.
Go for RelaxNG instead.