Creating XSLT nodes dynamically/multiple XSLT node

2019-08-30 22:46发布

I've been tasked with creating a form based on a government data form. I managed to download the XSD schema file for the form, and am trying to build an XSLT template based on the schema.

Here's the deal: the schema includes a complex element that allows (maxOccurs) up to five instances. Nested within it is another complex element that allows up to five occurrences. And nested within that is yet another complex element that allows up to 100 elements.

5 x 5 x 100 = 2500 elements? Ugh!!!

I'd really rather not write up to 2500 nodes in my XSL template (especially when they're the same nodes)!!! Is there any way to write my template file such that either (1) it creates the nodes dynamically, or (2) it includes some kind of attribute (I don't know if one exists -- I haven't been able to find anything) that tells it, "okay, this might repeat up to X number of times"?

Thanks in advance . . .

标签: xml xslt xsd
2条回答
等我变得足够好
2楼-- · 2019-08-30 23:24

Unless I misunderstand the question, all you need is a template match that will apply to each occurrence of the particular node.

Basic example of this can be found here.

If I don't understand the question, maybe you could provide clarifying detail.

查看更多
疯言疯语
3楼-- · 2019-08-30 23:27

After unsuccessfully looking for a solution to this, I bit the bullet, did a copy/paste of all my elements, and just hardcoded them into the XSLT. :-(

Probably not the best solution, I know, but it does what I need.

查看更多
登录 后发表回答