Jump to content

XSLT


shelley

Recommended Posts

Hello,I try to generate duplicate documents (PDF) via the same XML source. Is there any way to loop or tell xsl stylesheet to print multiple copies?  Thanks. :)

If you ask me, it's the application that executes the stylesheet that should be set to generate more copies, but If you have to do it within the stylesheet and don't have any other possiblity, try to add <xsl:apply-templates /> below the actual main template to execute it multiple times. Add as much <xsl:apply-templates /> as the additional copies you would like. If an infinite loop or something happens add the attribute "select" and as a value, use the match of the main template.
Link to comment
Share on other sites

when application executes the stylesheet it will generate a seperate file each time. What I want is to generate multiple copies in the same file.added <xsl:apply-templates /> I got java.lang.NullPointerException because it reaches the end of XML file.Any better way to read from the beginning of the XML file again.Thanks.

Link to comment
Share on other sites

Hmm, sounds like a funny one.Like Boen says - if you want to generate multiple copies, you need to decide whether the user or the application controls how many copies are generated first. Once you've decided the way to control the number of copies try something like :

<script language="VBscript" >Sub gen_copies(no_of_copies, source_doc, transform_doc, output_doc)Dim s_doc, t_doc, o_docSet s_doc = CreateObject("Microsoft.XMLDOM")s_doc.async = "false"s_doc.open source_docSet t_doc = CreateObject("Microsoft.XMLDOM")t_doc.async = "false"t_doc.open transform_docSet o_doc = CreateObject("Microsoft.XMLDOM")o_doc.async = "false"o_doc.open output_doc For counter = 1 to no_of_copieso_doc.write s_doc.transformnode(t_doc)Next counterEnd sub</script>

This is very rough code, but you can then submit your data (xml file)using source_doc, your transform (xsl file) is in transform_doc and your output file is in output_doc.You would probably have to change a lot of the code relating to o_doc to suit the format of your output, but this should give you an idea of how you could do it.Have fun.Dooberry :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...