C
Chris
Hi,
Maybe I've got a strange question.
I've got a XML document (main.xml) with several nodes. Additional I've
another XML docuement (role.xml), with allowed nodes. In a XSL-File I
just would like to extract nodes from the main.xml file, which were
declared in role.xml.
Example:
main.xml:
<main>
<firstname>Tom</firstname>
<lastname>Jones</lastname>
<street>Sunset 11</street>
<state>CA</state>
....
</main>
Role.xml:
<role>
<field>lastname</field>
<field>state</field>
</role>
So I just want to extract "lastname" (Jones) and "state" (CA) from the
main.xml.
I just tried following XSLT on Main.xml:
<xsl:template match="/">
<xsl:apply-templates select="document(Role.xml)/role"/>
</xsl:template>
<xsl:template match="role">
<xsl:for-each select="field">
<xsl:value-of select="/main//current()"/>
</xsl:for-each>
</xsl:template>
In match="role" all "fields" nodes from Role.xml are traversing. So
now each found node (lastname, state) should be selected in main.xml
(/main/lastname and /main/state). The XSL should output "Jones" and
"CA". But it seems that I can't use current() in the "<xsl:value-of
select=...".
Does anyone know a solution?
Thanks a lot for helping!
Maybe I've got a strange question.
I've got a XML document (main.xml) with several nodes. Additional I've
another XML docuement (role.xml), with allowed nodes. In a XSL-File I
just would like to extract nodes from the main.xml file, which were
declared in role.xml.
Example:
main.xml:
<main>
<firstname>Tom</firstname>
<lastname>Jones</lastname>
<street>Sunset 11</street>
<state>CA</state>
....
</main>
Role.xml:
<role>
<field>lastname</field>
<field>state</field>
</role>
So I just want to extract "lastname" (Jones) and "state" (CA) from the
main.xml.
I just tried following XSLT on Main.xml:
<xsl:template match="/">
<xsl:apply-templates select="document(Role.xml)/role"/>
</xsl:template>
<xsl:template match="role">
<xsl:for-each select="field">
<xsl:value-of select="/main//current()"/>
</xsl:for-each>
</xsl:template>
In match="role" all "fields" nodes from Role.xml are traversing. So
now each found node (lastname, state) should be selected in main.xml
(/main/lastname and /main/state). The XSL should output "Jones" and
"CA". But it seems that I can't use current() in the "<xsl:value-of
select=...".
Does anyone know a solution?
Thanks a lot for helping!