Subject: Re: [xsl] Best practices when reorganizing content? From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 21 Mar 2025 22:11:39 -0000 |
I've been studying this problem for a while now, and I think I have some of the answers but not all. XSLT 3.0 is certainly not especially good at processing JSON in the "recursive descent" style using template rules. One of the problems, as you say, is the absence of element names; another is the absence of parent pointers. We're incrementally adding features to the 4.0 spec to address the problems but I'm conscious that we haven't yet joined all the dots. You may find it interesting to read https://github.com/qt4cg/qtspecs/issues/1786 I would be interested in the detail of what JSON you are processing and what transformation you want to apply to it. We need this kind of input on use cases to come up with the right feature set for the 4.0 spec. Meanwhile, my Balisage 2022 paper gives a snapshot of my thinking at the time: https://www.balisage.net/Proceedings/vol27/html/Kay01/BalisageVol27-Kay01.htm l and draws on a couple of use cases of JSON transformations with 3.0 reported at XML Prague 2016 -- see https://www.saxonica.com/papers/xmlprague-2016mhk.pdf -- where sadly the conclusion was that it was often easier to convert the JSON to XML, do the transformation, and then convert it back. Michael Kay Saxonica > On 21 Mar 2025, at 20:37, dvint@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > My general stylesheet design is to try and leverage templates that match things and produce output as they are found in the document order. In some cases the templates will process the content and other times it will ignore/hide the content. If I'm worried the format will evolve I'll try and add a wildcard template <xsl:template match="*"> and report elements that weren't in my original source to trigger a review oof the output. > > That works well for me with something that is generally in the same order of output and content is nested nicely that I might ignore whole sections. > > I'm now trying to process JSON that was developed for a completly different purpose and the content has to be transformed in a very specific order. Also because it is coming from JSON i don't have nice element names to reference. > > Currently I start a template and then try and target the specific sections with if statements to make the decision to output or not - more procedural. > > I run the risk of missing additions to the content that I might want to do something with and I don't have a good way to try and report these additions and potential deletions. > > I've got a fair amount of content being managed and it has given me an idea of what is going on in the content that I didn't have when I started, such that I'm going to see if I can try a different approach. > > The other issues is that the content doesn't have any sort of model/scheam/dtd that is used to validate the results and it looks like anyone can add any structure (or not follow existing patterns) when ever they want. This structure has morphed over the last 2yrs of use so I have early content designs with more recent designs. > > What I'm trying to achieve: > - stylesheet that is less procedural > - reporting of new structures that I might want to look into > - error reporting when the content I receive doesn't match "my model view" of what was intended > > Any suggestions greaty appreciated. > > ..dan > > o?<
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Best practices when reorg, Martin Honnen martin | Thread | [xsl] Replace the portion of text t, Roger L Costello cos |
Re: [xsl] Best practices when reorg, Martin Honnen martin | Date | [xsl] Replace the portion of text t, Roger L Costello cos |
Month |