Hi I have following XAML code which is the output from XamlWriter.Save():
<StackPanel Name="itemStack" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mm="clr-namespace:MindManager;assembly=MindManager">
<mm:Item Width="Auto" Height="Auto">
<Border BorderThickness="10,10,10,10" Name="border1" Height="Auto">
<DockPanel>
<DockPanel LastChildFill="True" Name="dockPanel1" Height="33" DockPanel.Dock="Top">
<Button Name="deleteItemButton" Width="26" Height="21.638" FlowDirection="LeftToRight" DockPanel.Dock="Right" Grid.IsSharedSizeScope="False">x</Button>
<TextBox Name="tagsTextBox" Height="19">1</TextBox>
</DockPanel>
<TextBox TextWrapping="Wrap" MinLines="5" AcceptsReturn="True" AcceptsTab="True" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" AutoWordSelection="True" Name="contentTextBox" Width="Auto" MinWidth="600" Height="Auto" MinHeight="80">2</TextBox>
</DockPanel>
</Border>
</mm:Item>
<mm:Item Width="Auto" Height="Auto">
<Border BorderThickness="10,10,10,10" Name="border1" Height="Auto">
<DockPanel>
<DockPanel LastChildFill="True" Name="dockPanel1" Height="33" DockPanel.Dock="Top">
<Button Name="deleteItemButton" Width="26" Height="21.638" FlowDirection="LeftToRight" DockPanel.Dock="Right" Grid.IsSharedSizeScope="False">x</Button>
<TextBox Name="tagsTextBox" Height="19">3</TextBox>
</DockPanel>
<TextBox TextWrapping="Wrap" MinLines="5" AcceptsReturn="True" AcceptsTab="True" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" AutoWordSelection="True" Name="contentTextBox" Width="Auto" MinWidth="600" Height="Auto" MinHeight="80">4</TextBox>
</DockPanel>
</Border>
</mm:Item>
</StackPanel>
I want to convert it to simpler XML with the following XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:mm="clr-namespace:MindManager;assembly=MindManager">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/StackPanel">
<mindcontainer>
<xsl:for-each select="mm:Item">
<minditem>
<xsl:value-of select="/tagsTextBox"/>
<xsl:value-of select="/contentTextBox"/>
</minditem>
</xsl:for-each>
</mindcontainer>
</xsl:template>
</xsl:stylesheet>
I want the output to have the following format:
<mindcontainer>
<minditem>
content of tagsTextBox
content of contentTextBox
</minditem>
<minditem>
content of tagsTextBox
content of contentTextBox
</minditem>
</mindcontainer>
But the problem is that all I get from it is:
x
1
2
x
3
4
One can see that there is only text, there are not text, also the filter doesn't work the x is the label of the close button which I do not want to be outputted.
This is the code Iam using to perform the transform:
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent=true;
StringBuilder sb = new StringBuilder();
using (XmlWriter wr = XmlWriter.Create(sb, settings))
{
XamlWriter.Save(scrollViewer1.Content, wr);
}
settings.ConformanceLevel = ConformanceLevel.Auto;
using (XmlReader rd = XmlReader.Create(new StringReader(sb.ToString())))
{
XslCompiledTransform trans = new XslCompiledTransform();
trans.Load("output.xsl");
trans.Transform(rd, XmlWriter.Create("mindstore.xms", settings));
}