We have an ASP.NET C# website which generates letters using WordML, XSLT, XML, etc.
Users fill-in data on an ASPX page, which is then transferred to an XML file.
The data on the XML file is then sent to the XSLT file using FileStream.
Our issue is that when we use a table with multiple row and users only fill-in data for some of the rows, the unused rows show up as blank rows on the resulting Word document.
We are looking for a way to delete the unused/blank rows of this table.
Ben Aminnia
Member
46 Points
170 Posts
Deleting unused table rows in xslt
Nov 29, 2012 05:57 PM|LINK
I have an xslt file with a table for showing user entered values.
The table has been defined with 5 rows, but if the user enters data for only 3 rows, I need to be able to delete the unused rows #4 and #5.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Deleting unused table rows in xslt
Nov 30, 2012 05:54 AM|LINK
Hello,
So what have you done?
And what xslt have you got?
What actually happen?
Ben Aminnia
Member
46 Points
170 Posts
Re: Deleting unused table rows in xslt
Nov 30, 2012 03:06 PM|LINK
My table in XSLT has 6 rows and is defined like this (with first row containing column titles and five more rows for user entered data:
I'm posting some more details below.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Deleting unused table rows in xslt
Dec 01, 2012 02:05 AM|LINK
Sorry but your xml isn't right in syntax, because when I paste your xml contents into Vs, some errors are reported.
Ben Aminnia
Member
46 Points
170 Posts
Re: Deleting unused table rows in xslt
Dec 02, 2012 06:46 PM|LINK
Here are some more details:
We have an ASP.NET C# website which generates letters using WordML, XSLT, XML, etc.
Users fill-in data on an ASPX page, which is then transferred to an XML file.
The data on the XML file is then sent to the XSLT file using FileStream.
Our issue is that when we use a table with multiple row and users only fill-in data for some of the rows, the unused rows show up as blank rows on the resulting Word document.
We are looking for a way to delete the unused/blank rows of this table.
Here’s the XML file:
<Letters>
<Letter Number="CAL01">
<Quantity1>q1</Quantity1>
<Code1>c1</Code1>
<Description1>d1</Description1>
<Modifier1 />
<Quantity2 />
<Code2 />
<Description2 />
<Modifier2 />
<Quantity3 />
<Code3 />
<Description3 />
<Modifier3 />
<Quantity4 />
<Code4 />
<Description4 />
<Modifier4 />
<Quantity5 />
<Code5 />
<Description5 />
<Modifier5 />
</Letter>
</Letters>
Here’s the XSLT file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:ext="my extension" xmlns:v="urn:schemas-microsoft-com:vml" exclude-result-prefixes="msxsl ext">
<msxsl:script language="C#" implements-prefix="ext">
public static string EncodeBase64(string file) {
System.IO.FileInfo fi = new System.IO.FileInfo(file);
if (!fi.Exists)
return String.Empty;
using (System.IO.FileStream fs = System.IO.File.OpenRead(file)) {
System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
return Convert.ToBase64String(br.ReadBytes((int)fi.Length));
}
}
</msxsl:script>
<xsl:output method="xml" indent="yes" />
<xsl:template match="Letters/Letter">
<xsl:processing-instruction name="mso-application">
<xsl:text>progid="Word.Document"</xsl:text>
</xsl:processing-instruction>
<xsl:variable name="url">
<xsl:text>wordml://</xsl:text>
<xsl:number count="Letters/Letter" format="00000001" />
<xsl:text>.jpg</xsl:text>
</xsl:variable>
<w:wordDocument xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:wsp="http://schemas.microsoft.com/office/word/2003/wordml/sp2" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" w:macrosPresent="no" w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve">
<w:ignoreSubtree w:val="http://schemas.microsoft.com/office/word/2003/wordml/sp2" />
<o:SmartTagType o:namespaceuri="urn:schemas-microsoft-com:office:smarttags" o:name="stockticker" />
<w:divs>
<w:div w:id="17464068">
<w:bodyDiv w:val="on" />
<w:marLeft w:val="0" />
<w:marRight w:val="0" />
<w:marTop w:val="0" />
<w:marBottom w:val="0" />
<w:divBdr>
<w:top w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto" />
<w:left w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto" />
<w:bottom w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto" />
<w:right w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto" />
</w:divBdr>
</w:div>
<w:div w:id="925770450">
<w:bodyDiv w:val="on" />
<w:marLeft w:val="0" />
<w:marRight w:val="0" />
<w:marTop w:val="0" />
<w:marBottom w:val="0" />
<w:divBdr>
<w:top w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto" />
<w:left w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto" />
<w:bottom w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto" />
<w:right w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto" />
</w:divBdr>
</w:div>
</w:divs>
<w:shapeDefaults>
<o:shapedefaults v:ext="edit" spidmax="5122" />
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout>
</w:shapeDefaults>
<w:body>
<w:tbl>
<w:tblPr>
<w:tblW w:w="0" w:type="auto" />
<w:tblBorders>
<w:top w:val="single" w:sz="6" wx:bdrwidth="15" w:space="0" w:color="000000" />
<w:left w:val="single" w:sz="6" wx:bdrwidth="15" w:space="0" w:color="000000" />
<w:bottom w:val="single" w:sz="6" wx:bdrwidth="15" w:space="0" w:color="000000" />
<w:right w:val="single" w:sz="6" wx:bdrwidth="15" w:space="0" w:color="000000" />
<w:insideH w:val="single" w:sz="6" wx:bdrwidth="15" w:space="0" w:color="000000" />
<w:insideV w:val="single" w:sz="6" wx:bdrwidth="15" w:space="0" w:color="000000" />
</w:tblBorders>
<w:tblLayout w:type="Fixed" />
<w:tblLook w:val="0039" />
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w="1073" />
<w:gridCol w:w="873" />
<w:gridCol w:w="6802" />
<w:gridCol w:w="1620" />
</w:tblGrid>
<w:tr wsp:rsidR="002F379C">
<w:trPr>
<w:cantSplit />
</w:trPr>
<w:tc>
<w:tcPr>
<w:tcW w:w="1073" w:type="dxa" />
<w:shd w:val="pct-5" w:color="auto" w:fill="auto" wx:bgcolor="F2F2F2" />
</w:tcPr>
<w:p wsp:rsidR="002F379C" wsp:rsidRDefault="002F379C" wsp:rsidP="007A07E0">
<w:pPr>
<w:keepLines />
<w:rPr>
<w:b />
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b />
</w:rPr>
<w:t>Quantity</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="873" w:type="dxa" />
<w:shd w:val="pct-5" w:color="auto" w:fill="auto" wx:bgcolor="F2F2F2" />
</w:tcPr>
<w:p wsp:rsidR="002F379C" wsp:rsidRDefault="002F379C" wsp:rsidP="007A07E0">
<w:pPr>
<w:keepLines />
<w:rPr>
<w:b />
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b />
</w:rPr>
<w:t>Code</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="6802" w:type="dxa" />
<w:shd w:val="pct-5" w:color="auto" w:fill="auto" wx:bgcolor="F2F2F2" />
</w:tcPr>
<w:p wsp:rsidR="002F379C" wsp:rsidRDefault="002F379C" wsp:rsidP="007A07E0">
<w:pPr>
<w:keepLines />
<w:rPr>
<w:b />
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b />
</w:rPr>
<w:t>Description</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="1620" w:type="dxa" />
<w:shd w:val="pct-5" w:color="auto" w:fill="auto" wx:bgcolor="F2F2F2" />
</w:tcPr>
<w:p wsp:rsidR="002F379C" wsp:rsidRDefault="002F379C" wsp:rsidP="007A07E0">
<w:pPr>
<w:keepLines />
<w:rPr>
<w:b />
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b />
</w:rPr>
<w:t>Modifier</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
<w:tr wsp:rsidR="001D298E" wsp:rsidTr="007275D0">
<w:trPr>
<w:cantSplit />
</w:trPr>
<w:tc>
<w:tcPr>
<w:tcW w:w="1073" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Quantity1" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="873" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Code1" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="6802" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Description1" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="1620" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Modifier1" /></w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
<w:tr wsp:rsidR="001D298E" wsp:rsidTr="007275D0">
<w:trPr>
<w:cantSplit />
</w:trPr>
<w:tc>
<w:tcPr>
<w:tcW w:w="1073" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Quantity2" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="873" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Code2" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="6802" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Description2" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="1620" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Modifier2" /></w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
<w:tr wsp:rsidR="001D298E" wsp:rsidTr="007275D0">
<w:trPr>
<w:cantSplit />
</w:trPr>
<w:tc>
<w:tcPr>
<w:tcW w:w="1073" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Quantity3" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="873" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Code3" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="6802" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Description3" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="1620" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Modifier3" /></w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
<w:tr wsp:rsidR="001D298E" wsp:rsidTr="007275D0">
<w:trPr>
<w:cantSplit />
</w:trPr>
<w:tc>
<w:tcPr>
<w:tcW w:w="1073" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Quantity4" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="873" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Code4" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="6802" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Description4" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="1620" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="001D298E" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007275D0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Modifier4" /></w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
<w:tr wsp:rsidR="002F379C">
<w:trPr>
<w:cantSplit />
</w:trPr>
<w:tc>
<w:tcPr>
<w:tcW w:w="1073" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="002F379C" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007A07E0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Quantity5" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="873" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="002F379C" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007A07E0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Code5" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="6802" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="002F379C" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007A07E0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Description5" /></w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="1620" w:type="dxa" />
</w:tcPr>
<w:p wsp:rsidR="002F379C" wsp:rsidRDefault="003B7B2C" wsp:rsidP="007A07E0">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:r>
<w:t><xsl:value-of select="Modifier5" /></w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
</w:body>
</w:wordDocument>
</xsl:template>
</xsl:stylesheet>