I need to select a stylesheet at runtime based on an attribute in the input XML document. Outside of Babeldoc, I would write a SAX content handler to pick out the attribute I'm looking for, then use that to select a stylesheet.
To be able to apply a particular stylesheet at runtime in Babeldoc, would I need to integrate custom code into a pipeline?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would try using a Router or XPathExtract stage to set a document variable that is the stylesheet name, and then having the XSLTransform stage use the contents of the document variable as the stylesheet name.
Sherman
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I will have up to twenty stylesheets. Based on the value of the attribute, I would select one of the twenty stylesheets to apply. Right now I do this by loading a properties file where the key represents the attribute value and the value represents the stylesheet to apply. Can I apply this same logic within Babeldoc, or would I simply incorporate my current classes into a Babeldoc project?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can do this in Babeldoc in the following way, but it is not pretty.
1. XpathExtract the attribute into a document variable
2. A Router step to test the variable and call one of a number of steps.
3. These steps that set the right XSL file name in a document parameter.
4. Transform step to run the selected transform using the document variable.
It is probably simpler to have a custom stage that uses your properties file and does the right thing.
Sherman
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I need to select a stylesheet at runtime based on an attribute in the input XML document. Outside of Babeldoc, I would write a SAX content handler to pick out the attribute I'm looking for, then use that to select a stylesheet.
To be able to apply a particular stylesheet at runtime in Babeldoc, would I need to integrate custom code into a pipeline?
I would try using a Router or XPathExtract stage to set a document variable that is the stylesheet name, and then having the XSLTransform stage use the contents of the document variable as the stylesheet name.
Sherman
I will have up to twenty stylesheets. Based on the value of the attribute, I would select one of the twenty stylesheets to apply. Right now I do this by loading a properties file where the key represents the attribute value and the value represents the stylesheet to apply. Can I apply this same logic within Babeldoc, or would I simply incorporate my current classes into a Babeldoc project?
You can do this in Babeldoc in the following way, but it is not pretty.
1. XpathExtract the attribute into a document variable
2. A Router step to test the variable and call one of a number of steps.
3. These steps that set the right XSL file name in a document parameter.
4. Transform step to run the selected transform using the document variable.
It is probably simpler to have a custom stage that uses your properties file and does the right thing.
Sherman