Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
programming4us
Windows 7

Microsoft Visio 2010 : Creating rule set reports - Getting the XSL stylesheet

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
5/28/2012 3:39:17 PM
It is a relatively simple operation to use System.Xml.Xsl and System.Xml.XPath to iterate through the elements in the XDocument created by the getXDocument() method. The result is an HTML page that can be displayed in any browser.

The ReportDocument() method prompts for the name of an HTML document to output to.

public void ReportDocument(bool includeRulesets, bool includeIssues)
{
try
rules setsreports, creating{
string title = "";
if (includeRulesets) title += "RuleSets";
if (includeRulesets && includeIssues) title += " and ";
if (includeIssues) title += "Issues";
string shortName = System.IO.Path.GetFileNameWithoutExtension( this.document.FullName);
string fileName = System.IO.Path.Combine(this.document.Path, shortName + ".html");
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.Title = "Save " + title;
dlg.InitialDirectory = System.Environment.GetFolderPath( System.Environment.SpecialFolder.MyDocuments);
dlg.FileName = shortName + " " + title + ".html";
dlg.OverwritePrompt = true;
dlg.DefaultExt = ".html";
dlg.Filter = "HTML documents (.html)|*.html";
if (dlg.ShowDialog() == true)
{
fileName = dlg.FileName;
}
else return;
XDocument xDoc = getXDocument(includeRulesets, includeIssues);
if (xDoc == null)
{
return;
}
//Get the XSL Stylesheet
string xslMarkup = getRuleSetXSL();
// Load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(System.Xml.XmlReader.Create(new StringReader(xslMarkup)));
//Save the XDocument to a temporary file
string tempFile = System.IO.Path.GetTempFileName();
xDoc.Save(tempFile);
// Execute the transform and output the results to html.
xslt.Transform(tempFile, fileName);
//Delete the temporary file
System.IO.File.Delete(tempFile);
//Open in web browser (associated program)
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(fileName);
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
System.Diagnostics.Process.Start(startInfo);
}
catch (Exception)
rules set reportscreating{
throw;
}
}


					  

Getting the XSL stylesheet

The XSL template returned by this method can be saved as a file, say RuleSets.xslt, and can be used to transform the rule sets in any Visio document saved in XML format. The output will be a rule set report in HTML.

private string getRuleSetXSL()
{
return @"<?xml version='1.0' encoding='UTF-8' ?> <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' 
xmlns:vx= 'http://schemas.microsoft.com/visio/2006/extension' xmlns:v14= 'http://schemas.microsoft.com/office/visio/2009/5/extension' xmlns='http://schemas.microsoft.com/visio/2003/core'> <HTML> <BODY> <H1>Visio Rules Tools RuleSets Report</H1> </BODY> </HTML> <!--<xsl:template match='text()' />--> <xsl:template match='/'> <xsl:apply-templates select='//*/*/*/v14:RuleSet' /> </xsl:template> <xsl:template match='v14:RuleSet' > <HTML> <BODY> <H1>Visio Rules Tools RuleSets Report</H1> <xsl:for-each select='.'> rules set reportsXSL stylesheet, obtaining<TABLE width='100%'> <TR> <TABLE width='100%' frame='border' style='font-size:24px'> <TR style='background-color:teal;color:white; font-weight:bold'> <TH >ID</TH> <TH >NameU</TH> <TH >Name</TH> <TH >Description</TH> </TR> <TR style='background-color:azure'> <TD> <xsl:value-of select='@ID'/> </TD> rules setsreports, creating<TD> <xsl:value-of select='@NameU'/> </TD> <TD> <xsl:value-of select='@Name'/> </TD> <TD > <xsl:value-of select='@Description'/> </TD> </TR> </TABLE> </TR> <TR> <TABLE width='100%' frame='border' > <TR style='font-weight:bold; background-color:gray;color:white;padding:4px'> <TH>ID</TH> <TH>NameU</TH> <TH>Category</TH> <TH>Description</TH> <TH>RuleTarget</TH> <TH>RuleFilter</TH> <TH>RuleTest</TH> </TR> <xsl:for-each select='v14:Rule'> <TR style='vertical-align:top'> <TD > <xsl:value-of select='@ID'/> </TD> <TD > <xsl:value-of select='@NameU'/> </TD> <TD > <xsl:value-of select='@Category'/> </TD> <TD > <xsl:value-of select='@Description'/> </TD> <TD > <xsl:value-of select='@RuleTarget'/> </TD> <TD > <xsl:value-of select='v14:RuleFilter'/> </TD> <TD > <xsl:value-of select='v14:RuleTest'/> </TD> </TR> rules setsreports, creating</xsl:for-each> </TABLE> </TR> </TABLE> </xsl:for-each> </BODY> </HTML> </xsl:template> </xsl:stylesheet>"; }

Save the main body of the getRuleSetXSL() into a RuleSets.xslt file, then use XML Notepad to open a Visio XML format document.

You can then enter the full path to the RuleSets.xslt file on the XSL Output tab in XML Notepad, and press Transform. The Visio Rules Tools RuleSets Report will then be displayed.

Alternatively add the following line as line 2 in any XML file that contains rule sets (edit the href path accordingly):

<?xml-stylesheet type="text/xsl" href="RuleSets.xslt"?>

Open in your web browser to display the report!

Other -----------------
- Microsoft Access 2010 : Using Queries to Calculate Values & Creating a Parameter Query
- Microsoft Access 2010 : Using Criteria to Focus Query Results & Introducing Operators
- Microsoft Excel 2010 : Changing Summary Calculations, Showing and Hiding Data Items, Sorting Your Pivot Table
- Microsoft Excel 2010 : Changing the Pivot Table Layout, Customizing Field Names & Applying Numeric Formats to Data Fields
- Microsoft Word 2010 : Performing Mail Merges - Performing a Basic Mail Merge
- Microsoft Word 2010 : Performing Mail Merges - Performing a Basic Mail Merge
- Windows 7 User Mode Drivers Overview and Operation : Driver Callback Interfaces, UMDF Driver Features
- Windows 7 User Mode Drivers Overview and Operation : Devices Supported in User Mode & UMDF Model Overview
- Microsoft Project 2010 : Setting Up a Project Budget - Reviewing Cost Information
- Microsoft Project 2010 : Setting Up a Project Budget - Preparing for Cost Calculations
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server