Eduard Nickel
Eduard Nickel

Reputation: 155

How to get the child element of a node in xslt without know element name?

I am using WSO2 BPS 3.2.0 and I want to get child element of a node. Problem is that I don't know child element name at design time.

I have XML data

<Object>
    <document xmlns="http://schemas.org/doc/1.1">
        <type>...</type>
        <date>...</date>
    </document>
</Object>

or

<Object>
    <formular xmlns="http://schemas.org/doc/1.1">
        <formType>...</formType>
        <user>...</user>
    </formular>
</Object>

node <Object> could have any XML

I want to shave off the Object "envelope" and return inner XML. How to solve this by XSLT?

Thanks in advance.

Upvotes: 0

Views: 1001

Answers (1)

choroba
choroba

Reputation: 241978

You can use * to match any element:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/Object">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="*">
  <xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>

Upvotes: 3

Related Questions