I am using XML content in combination with others filter that automatically add some XML elements. Obviously, if the XML validation step of XML content occurs before these filters -- which it currently does -- then validation will fail because the proper XML elements are not inserted by the other filters.
The fix is running the other filters on the submitted text before XML Content validates. This is a bit recursive, since one of the filters is XML Content!
The hack is to shut off filtering for XML Content during the validation phase. The hack for that is to temporarily set the XSLT path to blank, and then set the value back. If Drupal does things right, this shouldn't be a performance hit on the Database. Unfortunately an error is probably logged in Watchdog.
If only the xmlcontent_nodeapi() function could provide a hint to _xmlcontent_transform() to not transform the document. Or if there was a way to disable filters in Drupal temporarily, that would work, too.
The patch for the gruesome hack is attached. It work goods good enough for me, for now.
| Comment | File | Size | Author |
|---|---|---|---|
| xmlcontent_5.x-1.x-dev_other-filters.patch | 776 bytes | ashawley |
Comments
Comment #1
weam commentedYou can control the order with which filters are invoked by editing the
weightcolumn of thefilterstable manually. Just give yourxmlcontentformat the highest weight in the table, and it will be invoked last in all node_api calls (includingvalidate). This is a drupal feature.If you want the output of one filter (that adds XML elements) to constitute the true input for the XSLT processor of XML Content, then I think you would be refering to filter pipelining; a concept I studied but delayed as I believe it might be overkill in drupal.
However I suggest that you add the new XML elements on your
node_submit, and save them with the node body, instead of using an input format to do that. That way it will not conflict with XML Content. Maybe you can set your XML Content filter to be non-validating if you don't need validation. That way it will do the XSLT as a best effort and will not stand in the way of your XML elements. I don't find changing drupal's way of invoking its api as a good thing, and I would leave that as a last resort.Comment #2
ashawley commentedThanks for you reply.
Input filter seems to be the wave of the future. As of 2007, Drupal has pipelined filters already configured by default.
I would like to use other input filters in combination with XML Content's validation system.
XML Content should be able to support these other input filters and validation. Can it be done?
There just needs to be a way to run the input filters in the validation routie. There is a way, running
check_markup($node->body, $format).There also needs to be a way to run those filters configured to run before XML Content should, and then stop. Well, I don't know if there is a way to do that. Instead, I just shut off filtering by XML Content's transformation by nulling the XSLT path. Fortunately, XML Content has also been my last input filter in the pipeline.
Comment #3
weam commentedCan you provide an example of the other filters?