XSLT如何将数据传递给父节点

XSLT如何将数据传递给父节点,xslt,Xslt,我正在使用XSLT解析.xsd文件。我的问题是我只能 在我正在访问的当前节点中找到输出数据时写入输出数据 使用 有没有办法将一些数据从节点发送到祖先节点 一个简单的例子,我得到了什么,我想要什么 --我当前的代码:-- --期望输出-- typedef int Type_in_元素; 结构T\u cp\u名称 { 在元素el\u name;中键入\//来自内部节点()的数据 }; 使用此 <xsl:template match="complexType"> <

我正在使用XSLT解析.xsd文件。我的问题是我只能 在我正在访问的当前节点中找到输出数据时写入输出数据 使用

有没有办法将一些数据从节点发送到祖先节点

一个简单的例子,我得到了什么,我想要什么

--我当前的代码:--

--期望输出--


typedef int Type_in_元素;
结构T\u cp\u名称
{
在元素el\u name;中键入\//来自内部节点()的数据
};
使用此

<xsl:template match="complexType">
        <xsl:text>typedef </xsl:text>
        <xsl:value-of select="//*/@type"/>
        <xsl:text> Type_in_</xsl:text>
        <xsl:value-of select="//*[@type]/name()"/>
        <xsl:text>;</xsl:text>
        <xsl:text>&#xa;</xsl:text>
        <xsl:text>struct </xsl:text>
        <xsl:text>T_</xsl:text>
        <xsl:value-of select="current()/@name"/>
        <xsl:text>&#xa;</xsl:text>
        <xsl:text>{</xsl:text>
        <xsl:text>&#xa;</xsl:text>
        <xsl:apply-templates select="sequence"/>
        <xsl:text>};</xsl:text> 
    </xsl:template>

    <xsl:template match="sequence">
        <xsl:apply-templates select="element"/>
    </xsl:template>

    <xsl:template match="element">
            <xsl:text>Type_in_</xsl:text>
            <xsl:value-of select="name()"/>
            <xsl:text> </xsl:text>
            <xsl:value-of select="@name"/>
        <xsl:text>; &#xa;</xsl:text>
    </xsl:template>

类型定义
输入_
;

;
结构
T_

;
{

;
}; 
输入_
; 
;
使用此

<xsl:template match="complexType">
        <xsl:text>typedef </xsl:text>
        <xsl:value-of select="//*/@type"/>
        <xsl:text> Type_in_</xsl:text>
        <xsl:value-of select="//*[@type]/name()"/>
        <xsl:text>;</xsl:text>
        <xsl:text>&#xa;</xsl:text>
        <xsl:text>struct </xsl:text>
        <xsl:text>T_</xsl:text>
        <xsl:value-of select="current()/@name"/>
        <xsl:text>&#xa;</xsl:text>
        <xsl:text>{</xsl:text>
        <xsl:text>&#xa;</xsl:text>
        <xsl:apply-templates select="sequence"/>
        <xsl:text>};</xsl:text> 
    </xsl:template>

    <xsl:template match="sequence">
        <xsl:apply-templates select="element"/>
    </xsl:template>

    <xsl:template match="element">
            <xsl:text>Type_in_</xsl:text>
            <xsl:value-of select="name()"/>
            <xsl:text> </xsl:text>
            <xsl:value-of select="@name"/>
        <xsl:text>; &#xa;</xsl:text>
    </xsl:template>

类型定义
输入_
;

;
结构
T_

;
{

;
}; 
输入_
; 
;

虽然您的答案解决了确切的示例,但我正在寻找一个更通用的解决方案,其中示例中的标记可以存在于树的任何位置和深度。虽然您的答案解决了确切的示例,但我正在寻找一个更通用的解决方案,其中示例中的标记可以存在于任何位置,在树的任何深处。
struct T_cp_name
{
 int el_name;
};
<!-- // First, use some data from the inner node (element) -->

typedef int Type_in_element;

<!-- // Then, use a combination of data from both the inner and the -->
<!-- // ancestor node (complexType) -->

struct T_cp_name
{
  Type_in_element el_name;  // data from the inner node (<element>)
};
<xsl:template match="complexType">
        <xsl:text>typedef </xsl:text>
        <xsl:value-of select="//*/@type"/>
        <xsl:text> Type_in_</xsl:text>
        <xsl:value-of select="//*[@type]/name()"/>
        <xsl:text>;</xsl:text>
        <xsl:text>&#xa;</xsl:text>
        <xsl:text>struct </xsl:text>
        <xsl:text>T_</xsl:text>
        <xsl:value-of select="current()/@name"/>
        <xsl:text>&#xa;</xsl:text>
        <xsl:text>{</xsl:text>
        <xsl:text>&#xa;</xsl:text>
        <xsl:apply-templates select="sequence"/>
        <xsl:text>};</xsl:text> 
    </xsl:template>

    <xsl:template match="sequence">
        <xsl:apply-templates select="element"/>
    </xsl:template>

    <xsl:template match="element">
            <xsl:text>Type_in_</xsl:text>
            <xsl:value-of select="name()"/>
            <xsl:text> </xsl:text>
            <xsl:value-of select="@name"/>
        <xsl:text>; &#xa;</xsl:text>
    </xsl:template>