Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Schema - Repeatable Element Values

Status
Not open for further replies.

Mokil

Programmer
Jun 7, 2001
15
GB
Hi there,

I wonder if anybody can help...I have an XML Schema which is applied to a Word document. This document is then saved as a WordML template and converted to XSLT. This XSLT is then used to transform XML files into Word documents.

I want to use the values of some elements multiple times.

If for example I have:

<Client>
<Title>Mr</Title>
<Name>Jackson</Name>
<BirthDate>1960-01-03</BirthDate>
</Client>

I may want to use the Title and Name to display a "Dear Mr. Jackson" line at the top of my template. I may also want to say "Thank you Mr. Jackson" at the bottom of the template.
As you can see, this means my schema needs to use the same element value twice. I can use min and maxOccurs to allow multiple occurrences, but the document then expects to have two client elements, one for the "Dear" line, and another for the "Thank you" line.

Does anybody have any suggestions? Can this be done, or will I need to output the client details multiple times when generating my XML files?

Thanks in advance guys.
 
I'm not sure I understand the process. How can you 'apply' a schema to a word document? Schema's don't process anything, they just validate it. How is WordML converted to XSLT? Post the file/example.

With XSLT all you need to do is output the value of the particular node wherever you want it.

Jon

"I don't regret this, but I both rue and lament it.
 
Hi Jon, thanks for the response.

Word 2003 allows you to create a template based on a XML schema (go to Tools/Templates and Add-Ins). This file is then saved as XML, and a Microsoft command-line utility (wml2xslt.exe) is used to generate a stylesheet for this XML template.

I can then transform XML documents using this stylesheet into fully-compliant Word documents.

My examples are too large to post.

What I am hoping to do is allow the same element value to be used repeatedly when connecting the schema to the Word document. You are correct, I can XPATH to this in XSLT but that means users will have to manually edit XSLT which is not good.
There doesn't appear to be a way to use a schema for this purpose but I thought I'd ask the question anyways.

Thanks for your help,
Mike.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top