471,306 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

Dataset Transformed to Word via XML

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.

Jan 6 '06 #1
6 2043
Looks like you need your XSLT to be able to create multiple output
documents.

You could do that with the exsl:document tag.
http://www.exslt.org/exsl/index.html
http://msdn.microsoft.com/library/de...ml06162003.asp

Cheers,
-Naraendira Kumar R.R.
~~~~~~~~~~~~~~~
<ji******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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.

Jan 7 '06 #2
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:office: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:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags">
<xsl:output 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:office: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:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags" w:macrosPresent="no"
w:embeddedObjPresent="yes" w:ocxPresent="no" xml:space="preserve">
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags" o:name="City" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags" o:name="Street"
/>
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags" o:name="address"
/>
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags"
o:name="country-region" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office: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"
/>

"Naraendira Kuma R.R." <na****@nospam.com> wrote in message
news:us*************@TK2MSFTNGP12.phx.gbl...
Looks like you need your XSLT to be able to create multiple output
documents.

You could do that with the exsl:document tag.
http://www.exslt.org/exsl/index.html
http://msdn.microsoft.com/library/de...ml06162003.asp

Cheers,
-Naraendira Kumar R.R.
~~~~~~~~~~~~~~~
<ji******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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.


Jan 8 '06 #3
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:office: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:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags">
<xsl:output 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:office: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:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
w:macrosPresent="no" w:embeddedObjPresent="yes" w:ocxPresent="no"
xml:space="preserve">
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags"
o:name="City" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags"
o:name="Street" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags"
o:name="address" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags"
o:name="country-region" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office: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>

Jan 9 '06 #4
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?

--
Naraendira Kumar R.R.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Jim Ryder" <no@chance.com> wrote in message
news:F0***********@newsfe1-win.ntli.net...
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:office: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:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags">
<xsl:output 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:office: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:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ns0="http://tempuri.org/PrintQueueTenancyLetterForm5DS.xsd"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
w:macrosPresent="no" w:embeddedObjPresent="yes" w:ocxPresent="no"
xml:space="preserve">
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags" o:name="City"
/>
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags"
o:name="Street" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags"
o:name="address" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office:smarttags"
o:name="country-region" />
<o:SmartTagType
o:namespaceuri="urn:schemas-microsoft-com:office: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"
/>

"Naraendira Kuma R.R." <na****@nospam.com> wrote in message
news:us*************@TK2MSFTNGP12.phx.gbl...
Looks like you need your XSLT to be able to create multiple output
documents.

You could do that with the exsl:document tag.
http://www.exslt.org/exsl/index.html
http://msdn.microsoft.com/library/de...ml06162003.asp

Cheers,
-Naraendira Kumar R.R.
~~~~~~~~~~~~~~~
<ji******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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.



Jan 9 '06 #5
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>

Jan 10 '06 #6
I bet this isn't the XML to which you are trying to apply the XSLT.

Snippet from your original post ...
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()); >>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: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?


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.

--
Naraendira Kumar R.R.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
"dfljfdlgldfj" <ji******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... 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>

Jan 12 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Brendan Reynolds | last post: by
1 post views Thread by Matthew Baskey | last post: by
1 post views Thread by Geoffrey Gallaway | last post: by
5 posts views Thread by Jason | last post: by
4 posts views Thread by Siu | last post: by
13 posts views Thread by Hrvoje Voda | last post: by
2 posts views Thread by Mike Stephens | last post: by
2 posts views Thread by kamil.nowicki | last post: by
4 posts views Thread by =?Utf-8?B?anAybXNmdA==?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.