1
Я разбираю файлы .xsd с помощью XSLT. Моя проблема в том, что я могу только написать выходные данные, поскольку я нашел его в текущем узле, который я посещаю используя.XSLT Как передать данные родительским узлам
Есть ли способ отправить некоторые данные с узла на узел-предк ?.
Простой пример того, что я получаю и хочу.
- Мой текущий код: -
<xsl:template match="complexType">
<xsl:text>struct </xsl:text>
<xsl:text>T_</xsl:text>
<xsl:value-of select"current/@name"/>
<xsl:text>{</xsl:text>
<xsl:text>
</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:value-of select"current/@type"/>
<xsl:text> </xsl:text>
<xsl:value-of select"current/@name"/>
</xsl:template>
- Мой исходный файл -
<complexType name="cp_name">
<sequence>
<element name="el_name" type="int" minOccurs="1" maxOccurs="1">
</element>
</sequence>
</complexType>
- Мой выходной ток: -
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>)
};
Хотя ваш ответ решает точный пример, я искал для более общего решения, где теги в примере может существует в любом месте, на любой глубине дерево. –
fer
, если он работает для вас, чем принять ответ. – Rupesh