0

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 . . .

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Not a few minutes after posting this, I came across that same w3schools link (don't know how I missed it earlier). I'm messing around with it to see what it does.
Well, I've been fighting with this thing, and haven't been able to get it to work. Part of the problem with the W3Schools description is that it's entirely geared toward reading XML into XSLT and generating HTML. I'm taking a web form (i.e. HTML), and am trying to generate XML output from XSLT. Nowhere in these instructions do I see anything that describes how to do this.
Ray K: So you have HTML as a starting point? Is it more specifically XHTML which should transform just like XML? There are some gotchas. See stackoverflow.com/questions/16711842 for example and related questions.
Affirmative; it is an HTML form, not XHTML. I posted a question that asks exactly that here: stackoverflow.com/questions/21920756/… I will make it a point to check that link.
I was able to successfully set up my HTML XPath to get processed by the XSLT (see my solution here: stackoverflow.com/questions/21920756/…). However, I still can't get it to process unless I explicitly write out the elements in the XSLT. I am not about to write 2500 elements!!!
|
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.