Suggestions

Scott Deboy SCODEB at saif.com
Wed Apr 14 17:21:04 BST 1999


Thanks for the suggestions, James

Yes, this is 80% of what I'm looking for.  The other 20% is:

If I could 'include' a reference to the optional paragraph (which will live
in a database) instead of directly embedding it in the XSL template (I want
to reuse the same optional paragraph in a number of documents).  

What if I store the paragraph references as database selects in the XSL
template and do the work of retrieving them from the database before the XSL
engine does its work?  Is there a better way?

It sounds like it's time to read up on XSL.  

Scott

> ----------
> From: 	James Tauber[SMTP:jtauber at jtauber.com]
> Sent: 	 April 13, 1999 10:42 PM
> To: 	Scott Deboy
> Cc: 	'xml-dev at ic.ac.uk'
> Subject: 	Re: Suggestions
> 
> Scott Deboy wrote:
> > 
> > I'm new to XML (reading the spec and learning about DTDs etc.) and I was
> > hoping someone could point me in the right direction on an idea I have
> to
> > replace Word macros w/a 3-tier system using XML.
> > 
> > Example: I want to build a letter macro using XML.
> > 
> > The letter is mostly static text.  An address is required, as well as a
> > couple of other fields.  Also, the letter has a couple of optional
> > paragraphs that I need to prompt the user to answer.
> 
> A better approach would be to represent the user provided information as
> an XML document which is then given to an XSL engine to add the static
> text. So your template/macro would be a combination of a DTD
> constraining user-provided information, and an XSL stylesheet that takes
> that information and produces the output.
> 
> Here's a really simple example.
> 
> Say you are writing thank you notes for an engagement party.
> 
> For each person you have a document like:
> 
> <Person wedding="yes">
>   <Name>John</Name>
>   <Gift>vase</Gift>
> </Person>
> 
> that indicates the person's name, what gift they gave and whether they
> are coming to the wedding. Here's a DTD:
> 
> <!ELEMENT Person (Name,Gift)>
> <!ATTLIST wedding (yes|no) #REQUIRED>
> <!ELEMENT Name (#PCDATA)>
> <!ELEMENT Gift (#PCDATA)>
> 
> You then have an XSL stylesheet with a template such as:
> 
> <xsl:template match="Person">
>   <P>Dear <xsl:value-of select="Name"/>,</P>
>   <P>Thank you so much for your <xsl:value-of select="Gift"/>.</P>
>   <xsl:choose>
>     <xsl:when test='.[wedding="yes"]'>
>       <P>Look forward to seeing you at the wedding.</P>
>     </xsl:when>
>   <xsl:choose>
>   <P>James</P>
> </xsl:template>
> 
> Is this the sort of thing you wanted to do?
> 

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list