Dataset Transformed to Word via XML

J

jimryder

Hi,

The following snippet:

(ds is a populated dataset)

string sXSLT = @"C:\XML\template\template.xsl";
string sTemp = @"C:\XML\temp\temp.xml";
string sOutput = @"C:\XML\output\output.xml";
ds.WriteXml(sTemp);
XslTransform xslt = new XslTransform();
xslt.Load(sXSLT);
xslt.Transform(sTemp, sOutput, new XmlUrlResolver());


creates an XML word document which, when opened, loads fine - in other
words It is generating my word document OK.

However, assuming the dataset contains more than one row, then only
one word document is created, with the body of the document repeated
over and over - rather than one document per dataset row.
Is there any way to create a document per dataset row (other that
ensuring the dataset only contains one row!)??

Thanks in advance.
 
D

dfljfdlgldfj

Thanks for that - where does the exsl:document bit goes exactly - here
is a snippet of my template:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:blush:ffice:word"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:blush:="urn:schemas-microsoft-com:blush:ffice:blush:ffice"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:st1="urn:schemas-microsoft-com:blush:ffice:smarttags">
<xsl:blush:utput method="xml" encoding="UTF-8" standalone="yes" />
<xsl:template match="/">
<xsl:processing-instruction name="mso-application">
<xsl:text>progid="Word.Document"</xsl:text>
</xsl:processing-instruction>
<w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:blush:ffice:word"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:blush:="urn:schemas-microsoft-com:blush:ffice:blush:ffice"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:st1="urn:schemas-microsoft-com:blush:ffice:smarttags"
w:macrosPresent="no" w:embeddedObjPresent="yes" w:blush:cxPresent="no"
xml:space="preserve">
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:blush:ffice:smarttags"
o:name="City" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:blush:ffice:smarttags"
o:name="Street" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:blush:ffice:smarttags"
o:name="address" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:blush:ffice:smarttags"
o:name="country-region" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:blush:ffice:smarttags"
o:name="place" />
<o:DocumentProperties>
<o:Title>Form4B</o:Title>
<o:Author>Bowe</o:Author>
<o:LastAuthor>Jim Ryder</o:LastAuthor>
<o:Revision>2</o:Revision>
<o:TotalTime>1</o:TotalTime>
<o:LastPrinted>2003-02-13T16:16:00Z</o:LastPrinted>
<o:Created>2006-01-05T15:51:00Z</o:Created>
<o:LastSaved>2006-01-05T15:51:00Z</o:LastSaved>
<o:pages>2</o:pages>
<o:Words>340</o:Words>
<o:Characters>1944</o:Characters>
 
J

Jim Ryder

That's great thanks - can you/anyone help with my document - I can't work
out where to put the exsl:document tag? Ive tried a few optios:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:blush:ffice:word"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:blush:="urn:schemas-microsoft-com:blush:ffice:blush:ffice"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:st1="urn:schemas-microsoft-com:blush:ffice:smarttags">
<xsl:blush:utput method="xml" encoding="UTF-8" standalone="yes" />
<xsl:template match="/">
<xsl:processing-instruction name="mso-application">
<xsl:text>progid="Word.Document"</xsl:text>
</xsl:processing-instruction>
<w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:blush:ffice:word"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:blush:="urn:schemas-microsoft-com:blush:ffice:blush:ffice"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:st1="urn:schemas-microsoft-com:blush:ffice:smarttags" w:macrosPresent="no"
w:embeddedObjPresent="yes" w:blush:cxPresent="no" xml:space="preserve">
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:blush:ffice:smarttags" o:name="City" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:blush:ffice:smarttags" o:name="Street"
/>
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:blush:ffice:smarttags" o:name="address"
/>
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:blush:ffice:smarttags"
o:name="country-region" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:blush:ffice:smarttags" o:name="place"
/>
<o:DocumentProperties>
<o:Title>Form4B</o:Title>
<o:Author>Bowe</o:Author>
<o:LastAuthor>Jim Ryder</o:LastAuthor>
<o:Revision>2</o:Revision>
<o:TotalTime>1</o:TotalTime>
<o:LastPrinted>2003-02-13T16:16:00Z</o:LastPrinted>
<o:Created>2006-01-05T15:51:00Z</o:Created>
<o:LastSaved>2006-01-05T15:51:00Z</o:LastSaved>
<o:pages>2</o:pages>
<o:Words>340</o:Words>
<o:Characters>1944</o:Characters>
<o:Company>NCHA</o:Company>
<o:Lines>16</o:Lines>
<o:paragraphs>4</o:paragraphs>
<o:CharactersWithSpaces>2280</o:CharactersWithSpaces>
<o:Version>8.5425</o:Version>
</o:DocumentProperties>
<w:fonts>
<w:defaultFonts w:ascii="Times New Roman" w:fareast="Times New
Roman" w:h-ansi="Times New Roman" w:cs="Times New Roman" />
</w:fonts>
<w:lists>
<w:listDef w:listDefId="0">
<w:lsid w:val="00C65B6C" />
<w:plt w:val="Multilevel" />
<w:tmpl w:val="00000000" />
<w:lvl w:ilvl="0">
<w:start w:val="1" />
<w:lvlText w:val="%1." />
<w:legacy w:legacy="on" w:legacySpace="0" w:legacyIndent="720"
/>
 
N

Naraendira Kuma R.R.

It is hard to suggest, by just looking at the XSLT.

Can you post a sample XML & call out which XML nodes, you want to go to a
seperate document?
 
D

dfljfdlgldfj

Hmmmm... I think(!) I understand your question:

The template above is generated by the MS Word XML toolbar. All I then
do is apply my dataset to it. The typed dataset looks like this:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="PrintQueueTenancyLetterForm5DS"
targetNamespace="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
elementFormDefault="qualified" attributeFormDefault="qualified"
xmlns="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:mstns="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="PrintQueueTenancyLetterForm5DS"
msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="PrintQueueTable">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Address1"
type="xs:string" />
<xs:element name="Address2"
type="xs:string" minOccurs="0" />
<xs:element name="Address3"
type="xs:string" minOccurs="0" />
<xs:element name="PostCode"
type="xs:string" minOccurs="0" />
<xs:element name="IncreaseDate"
msdata:ReadOnly="true" type="xs:dateTime" minOccurs="0" />
<xs:element name="EffectiveDate"
msdata:ReadOnly="true" type="xs:dateTime" minOccurs="0" />
<xs:element name="TenancyPK"
msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" />
<xs:element name="PropertyFK" type="xs:int"
/>
<xs:element name="PeriodFK" type="xs:int"
/>
<xs:element name="Charge" type="xs:decimal"
/>
<xs:element name="Variation"
type="xs:decimal" />
<xs:element name="ApprovedBy"
type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
 
N

Naraendira Kuma R.R.

I bet this isn't the XML to which you are trying to apply the XSLT.

Snippet from your original post ...
If you post the a snippet of the XML document (temp.xml) and tell us which
nodes you want to go into each Word document, somebody on this group might
be able to help you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top