修改现有的 xml 以包含标题部分。我正在尝试将“Header”元素的嵌套子元素“按原样”复制到另一个 xml 文件中,但不能。
带有 Header 元素的 XML:
<?xml version="1.0" encoding="utf-8"?>
<QuestionText
xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents"
xmlns:s="clr-namespace:Telerik.Windows.Documents.Model.Styles;assembly=Telerik.Windows.Documents"
xmlns:r="clr-namespace:Telerik.Windows.Documents.Model.Revisions;assembly=Telerik.Windows.Documents"
xmlns:n="clr-namespace:Telerik.Windows.Documents.Model.Notes;assembly=Telerik.Windows.Documents"
xmlns:th="clr-namespace:Telerik.Windows.Documents.Model.Themes;assembly=Telerik.Windows.Documents"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
**<Header>
<t:SubHeader SubHeaderAtt1="valA" SubHeaderAtt2="valB">
<t:SubSubHeader SubSubHeaderAtt1="valX" SubSubHeaderAtt2="valY">
</t:SubSubHeader>
</t:SubHeader>
<t:SubHeader SubHeaderAtt1="valC" SubHeaderAtt2="valD">
<t:SubSubHeader SubSubHeaderAtt1="valM" SubSubHeaderAtt2="valN">
</t:SubSubHeader>
</t:SubHeader>
</Header>**
<Content>
<p ListId="2" xmlns="">
<span StyleName="ss">Item 1</span>
</p>
<p ListId="2" xmlns="">
<span>Item 2</span>
</p>
<p ListId="2" xmlns="">
<span>Item 3</span>
</p>
<p ListId="3" xmlns="" />
</Content>
</QuestionText>
XSD 复制标头:
<?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:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents"
xmlns:s="clr-namespace:Telerik.Windows.Documents.Model.Styles;assembly=Telerik.Windows.Documents"
xmlns:r="clr-namespace:Telerik.Windows.Documents.Model.Revisions;assembly=Telerik.Windows.Documents"
xmlns:n="clr-namespace:Telerik.Windows.Documents.Model.Notes;assembly=Telerik.Windows.Documents"
xmlns:th="clr-namespace:Telerik.Windows.Documents.Model.Themes;assembly=Telerik.Windows.Documents">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="QuestionText">
<t:RadDocument>
<xsl:copy>
<xsl:value-of select="Header/node()"/>
</xsl:copy>
<t:Section>
<!-- Avoided for brevity -->
</t:Section>
</t:RadDocument>
</xsl:template>
</xsl:stylesheet>
预期输出:
<?xml version="1.0" encoding="utf-8"?>
<t:RadDocument xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents"
xmlns:s="clr-namespace:Telerik.Windows.Documents.Model.Styles;assembly=Telerik.Windows.Documents"
xmlns:r="clr-namespace:Telerik.Windows.Documents.Model.Revisions;assembly=Telerik.Windows.Documents"
xmlns:n="clr-namespace:Telerik.Windows.Documents.Model.Notes;assembly=Telerik.Windows.Documents"
xmlns:th="clr-namespace:Telerik.Windows.Documents.Model.Themes;assembly=Telerik.Windows.Documents"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<t:SubHeader SubHeaderAtt1="valA" SubHeaderAtt2="valB">
<t:SubSubHeader SubSubHeaderAtt1="valX" SubSubHeaderAtt2="valY">
</t:SubSubHeader>
</t:SubHeader>
<t:SubHeader SubHeaderAtt1="valC" SubHeaderAtt2="valD">
<t:SubSubHeader SubSubHeaderAtt1="valM" SubSubHeaderAtt2="valN">
</t:SubSubHeader>
</t:SubHeader>
<t:Section>
<!-- Avoided for brevity -->
</t:Section>
</t:RadDocument>
如果有人能解释我缺少什么或如何解决这个问题,我将不胜感激。任何帮助都可以。