We are planning to use Saxonica EE (yet to buy) in Spring Boot microservice on Cloud Foundry and we want to store the XSLT compiled version in XML in Redis cache so that when do transformation it would be less time consuming, I have below questions, can you please guide me in right direction.
how can we deploy Saxon EE libs with licence to the cloud, any standard practice need to be followed.
is it possible to get the XSLT compiled code in XML format so that I can store in Redis cache, is this approach make sense (if there is any change in XSLT I will re-compile every time)
Any java programming samples, we use xsl:include heavily in all xsls , if there is any example for the same use-case would be great.
For the commercial questions regarding licensing for cloud deployment, that's out of scope for StackOverflow - please contact Saxonica directly to discuss this.
Saxon-EE can compile a stylesheet to a SEF file which is indeed an XML format, but I've no idea whether storing the compiled stylesheets in Redis makes any sense.
If you have a problem using xsl:include, I suggest you raise it as a separate question. A general request for advice on using a particular feature isn't likely to elicit helpful responses - StackOverflow works best if you have a specific technical question, or a specific technical problem. (If you want general advice, my XSLT reference book has about 4 pages on xsl:include, with examples).
I recommend you to start by getting the basic foundation of clarity in place as described below:
About choosing Redis for storage :
If your going for Redis as storage you normally would have to serialize your (XSLT processed) output into XML or JSON prior to storing it into Redis. This means also that any time you want to access the data in a more human-friendly readable way, you would have to deserialize the Redis string.
Answers on your bulleted questions (in relation to XSLT) :
[1] Cloud deployment: Even if you would like to use cloud solutions you would still need to define on which server you would like to install Java/SDK and Saxon libraries (jar). In terms of details around license for cloud solution, I would refer to the company Saxonica.
[2] Need of compiling: Saxon XSLT is not normally being compiled by user (unless there is a reason for it). I suspect when you say "compiled" in this bullet that you mean the transformation process, using a source XML, XSLT for processing and getting an output XML. - If so, you can set which output format you want (XML/HTML/XHTML). Every time you change something in your source- or XSL file, you would need to run XSLT to see the change in the XML output file.
[3] Need of Java samples: You do not need Java knowledge to build XSL stylesheet files. The Java comes into the picture if you choose to run on Java you would need to setup Java/SDK on the machine that would run Saxon XSLT. After the setup (Java/SDK and XSLT) you can choose between calling XSLT from a terminal or create scripts that would call XSLT (I use bash scripts in Linux).
I recommend that you start using an online XSLT tool meanwhile you solve your Java environment and Saxon XSLT. This way you can build up your XSL files or test any of your existing XSL files in order to adjust them to your needs.
Related
Can Adobe Experience Manager be used to make xsl files that convert xml into html?
If yes, please explain how to do it.
The short answer is yes Adobe Experience Manager (AEM) can be used to generate XSL and then use it to convert XML into HTML. Depending on what you are trying to accomplish, that may not be the best way to go about it.
From the question it's not clear but it sounds like you want to make an XSL with AEM. Typically a developer would create the XSL one time and then apply it to the XML to get your HTML. You can provide pretty elaborate XSL which should work for all cases. If did want to generate an XSL you would need to write custom code to accomplish this. The best way is to probably create a workflow task to create the XSL file in your AEM repository for later use.
The next step is to decide when you want to generate your HTML. Is it at request time which can be expensive or when you do a create or update on the XML? If it's when the request is made you would need to create a servlet using an XSLT library. Here's more information on how to do that from another thread XSLT processing with Java?. If you want to generate the HTML rendition whenever the XML is created or updated you'll need to create a workflow task and register it to launch each time a create or update happens on that file type. You'll also need to create a servlet to render the html you've generated.
You've asked a complex question without giving much information so I'm not sure either solution is the best scenario for goal. It might be easier to convert your xml into an AEM package and create nodes in the repository. Then you can render the HTML using Sightly
I am trying to use Saxon to programmatically generate an XSLT. This is a similar question to Create xslt files programmatically, but as there was no acceptable answer to that question I am asking again, specifically around Saxon which at one point claimed to support this.
According to http://saxon.sourceforge.net/saxon7.0/api-guide.html, "This document describes how to use Saxon as a Java class library, without making any use of XSLT stylesheets."
(answering the other question I referred to above) and then serialize that to a stylesheet that could then be reloaded and executed later, but I already pretty much figured out that isn't going to happen.
If Saxon isn't the answer, what Java library will support any of this?
By the way, doing any and all of this using .Net is trivial. Unfortunately I need a Java solution for this.
Any help is greatly appreciated.
Well, for a start, there have been 26 major releases and innumerable maintenance releases of Saxon since release 7.0, so forget anything you read there.
It's not clear from your question whether you want to write your XSLT code generator in Java or in XSLT. I can't see why you would want to do it in Java rather than XSLT, but neither is difficult. The main problem with your question is that you don't explain why you think it's a problem. Generating an XSLT stylesheet is just like generating any other XML document: what's the problem?
I figured this out a while ago, and thought I would share my answer. This may or may be an answer for Create xslt files programmatically as well, but since that was not my question, I won't assume that.
The answer is not to use XSLT (or Saxon) at all. Originally I wanted an API with which to generate an XSLT model where the rules for transforming a particular (xml) tree structure are known programmatically. Then the model could be persisted as a style sheet so that it could be reloaded and used to transform another tree with the same structure again. Sure I could programmatically create a DOM containing an XSLT style sheet document, but why would I want to? It's inefficient for one - creating and saving a DOM with all the XSLT syntax (tedious), and then reading it using SAXON, etc. I'd rather have an API that natively understands XSLT - maybe one that has an XSLT model that can just be programmed and then serialized?
Anyway, the answer to my problem is just to use SAX. Since I know the particular transformation rules for my tree programmatically, I simply created a handler that processes the stream using the rules, and I'm done. In the end there's no XSLT style sheet that can live outside the program, but I'll live with that.
And I take back what I said about .Net supporting my first approach. I thought it would so it's just a reminder to check your assumptions before you post.
By the way, an answer to my question suggested that it was easy to accomplish but rather than outline how to do it, I was just questioned why I would want to. Can we at least try to answer a question if we also feel we need to ask someone why they are asking a question?
I am designing a layout for my crm project now.
Now i am ended with 2 options one is sitemesh to define the layout or XSLT to define a layout.
Sitemesh will run at runtime from the server , it wont cause any issue if the number of request is high?
I guess XSLT will run at the browser based on the Xpath , is this correct?
Which one is better to use?
Please help me
Thanks
You can run XSLT either in the browser or at the server. The advantage to running it at the server is that the HTML you generate will be the same regardless of what browser the user has. If you run it in the web browser, users with different browsers might get slightly different results, because different XSLT transformation engines have different quirks, kind of like different web browsers do when rendering the same HTML and CSS.
I've designed and taught a corporate 1-day intro to XSLT class. I love the way XSLT works. That said, it has been criticized for running slowly and being hard to learn.
I've just started using SiteMesh 2.0, and I really like it. If you are not familiar with XSLT coding, you may be more comfortable with SiteMesh, because it simply wraps your content with a header/footer you create. You don't have to write and debug XSLT code.
I want the DocBook documents in my SVN repository to look nice if someone looks at them in a web browser. I've started to write a CSS stylesheet, but I think that it will have significant limitations -- particularly ones regarding hyperlinks.
There is a large body of DocBook XSL stylesheets at the DocBook site , but they don't seem to be appropriate for browser rendering. I don't want to generate static documents and put them into SVN. I want them to be basically readable for other developers without much hassle.
I could write my own browser-appropriate XSL stylesheet to convert DocBook to HTML, but it seems like someone else must have already done this. I just don't know where to find it.
In a past life I used wysiwygdocbook: http://www.cs.hs-rm.de/~werntges/proj/wysiwyg-dbk01.html
You are right, the DocBook XSL stylesheets are very heavy, and are not really suitable for running in a browser. The DocBook Wiki lists some CSS stylesheets, perhaps one of those might work for you?
The only one I have experience of is the one which XMLMind XML Editor apparently uses to present DocBook documents.
I've done some XSLT+CSS very basic and incomplete implementation for browserside DocBook styling. You can check it out here http://github.com/arsi/db2xhtml
But I would like to see more advanced project if available somewhere!
[Edited because I misread the question]
You certainly wouldn't want to run the stylesheets via a browser and the PI but then you wouldn't want to do that for any reasonably complex content. Do it server side if you're running over a web server or as a batch task. Is there any way that you can interpose a server side process in svn?
DocBook is a complex 'language' and capturing even most of the subleties of DocBook is very difficult. Using the DocBook XSL is not complex at all and I really would recommend you go in that direction if you can. The stylesheets are designed to be customised and are extremely well documented by Bob Stayton in DocBook XSL: The Complete Guide.
After quite a bit of searching, I believe the answer is "there is not a nice XSL stylesheet for client-side DocBook rendering," besides the bespoke ones like the one I implemented.
Typically you'd produce a 'rendition' for reading/display. The rendition can either be PDF, a single HTML page, or set of HTML pages. It's rare that you deliver docbook directly to web.
Can I ask what you're trying to accomplish and why?
Is this for internal delivery or external?
I hate getting the question that asks "can your technology do X?" It assumes a lot of knowledge about the product (plus, usually the answer is "yes" but that doesn't answer the real question). It's always best when I ask -- "what are you trying to accomplish" -- so I can tell you whether or not any piece of technology is a good fit (or I can point you to some other piece that's a much better fit, or a better way to go about it).
I'm looking for an XSL lint tool which is actively maintained. The only one I can find is this one, but the last update was in 2000 (9 years old!). Any help would be great!
Phillip,
Creating a good lint for xlst is quite hard, because validity of xslt templates depends on the parser that is used. Each parser has it own extensions.
For example java's xalan can be easily extended with custom xpath functions, which are obviously coded in java. Because of that any .net validator will fail to validate advance xalan's xslts.
So first of all you need to know what processor you are going to use. If you use java based processors I recommend to use Eclipse which can validate the templates on the fly.
I've tired two eclipse plugins, It is worth mentioning that both support debugging and xslt/xpath code completion:
Oxygen XML editor - a commercial (~$300) XML/XSLT editor/eclipse plugin.
It can use the following engines: Xalan, Saxon, Xsltproc,
It is able to check:
correctness of xsl:template
correctness of name attribute of xsl:call-template
duplicated definition of xslt variables
validity of dtd's
validity of xslt header
validity of xml namespaces
validity of XPath
validity of xsl:value-of if an xml is associated to xslt
correctness of xsl:import for local and remote files (it support xml catalogs)
I must say that the plugin is really good but on the other hand it isn't open source.
XSLT Project - an open source plugin (it is part of Eclipse Web Tools Platform).
It is quite young (started in September 2008), however it has very active community. Currently it supports only Xalan and JAXP.
It detects the following errors and warnings:
invalid xslt header
incorrect dtd
incorrect imports (it handle only relative imports, xml catalogs are planed for version
1.1)
The above list is definitely incomplete because lack of support for xml catalogs made this project unusable for me.
Yes, look at this one, published Dec. 2008:
http://lists.xml.org/archives/xml-dev/200812/msg00178.html
You should look for "XSL profiler" or "XSL debugger". There are dozens of these.