I could not retrieve xml attrubutes from xml inputs




<?xml version="1.0" encoding="UTF-8"?>
<p:transformOutput xmlns:p="http://cfpe/export/objects">
<p:objectSet>
<p:objects>
<p:object>
<p:objectAttributes>
<p:objectType>a</p:objectType>
<p:attribute name="x">F600</p:attribute>
<p:attribute name="y">A100</p:attribute>
<p:attribute name="z">D400</p:attribute>
</p:objectAttributes>
</p:object>
<p:object>
<p:objectAttributes>
<p:objectType>b</p:objectType>
<p:attribute name="x">F600</p:attribute>
<p:attribute name="y">C300</p:attribute>
<p:attribute name="z">B200</p:attribute>
</p:objectAttributes>
</p:object>
<p:object>
<p:objectAttributes>
<p:objectType>b</p:objectType>
<p:attribute name="x">a</p:attribute>
<p:attribute name="y">A100</p:attribute>
<p:attribute name="z">B200</p:attribute>
</p:objectAttributes>
</p:object>
</p:objects>
</p:objectSet>

<ns1:Templates>
<ns1:Template>
<ns1:System_Class>a</ns1:System_Class>
<ns1:System_Table>A100</ns1:System_Table>
<ns1:System_Attribute>aA</ns1:System_Attribute>
</ns1:Template>
<ns1:Template>
<ns1:System_Class>b</ns1:System_Class>
<ns1:System_Table>B200</ns1:System_Table>
<ns1:System_Attribute>bB</ns1:System_Attribute>
</ns1:Template>
</ns1:Templates>


xsl



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://ift.tt/tCZ8VR"
xmlns:p="http://cfpe/export/objects" xmlns:ns1="http://cfpe/export/objects"
exclude-result-prefixes="p">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="/p:transformOutput">
<objects>
<xsl:for-each select="p:transformOutput/p:objectSet/p:objects/p:object">
<object type="{p:objectAttributes/p:objectType}">
<xsl:variable name="attributes" select="p:objectAttributes/*" />
<xsl:variable name="matching-template" select="p:transformOutput/ns1:Templates/ns1:Template[ns1:System_Class=$attributes and ns1:System_Table=$attributes]" />
<template>
<xsl:value-of select="tns:System_Attribute"/>
</template>
</object>
</xsl:for-each>
</objects>
</xsl:template>

</xsl:stylesheet>


matching-template doesn't seem to find the value path. I was trying to compare System_Class if exists in objectAttributes and get the System_Attribute from if the value of the System_Attribute doesn't exist in the objectAttributes


No comments:

Post a Comment