Hi,
I'm attempting to convert an XML document to text and I would be grateful for any advice that you may have.
I have an XML document that uses node attributes quite a lot - the attribute name is always "value" even though the tag name can differ - below is an example:
<Facility>
<Header>
<Action value="Create"/>
</Header>
<Key>
<BAAPID value="TX34"/>
<PRCD value="920431"/>
</Key>
<Data>
<ALTYNA value="TX PDT"/>
<ISTYALID value="TX34-USD-LP-F"/>
<COFL value="N"/>
</Data>
<Event>
<Header>
<Action value="Create"/>
</Header>
<Key>
<EVURRE value="limit amount"/>
</Key>
<Data>
<EVSETYNA value="LINE-EVENTS"/>
<EVTYNA value="START"/>
<EVAM value="-7000000"/>
<EVDA value="2006-05-31"/>
<EVCU value="USD"/>
</Data>
</Event>
<Event>
<Header>
<Action value="Create"/>
</Header>
<Key>
<EVURRE value="limit expiry"/>
</Key>
<Data>
<EVSETYNA value="LINE-EVENTS"/>
<EVTYNA value="END"/>
<EVAM value="0"/>
<EVDA value="2006-06-30"/>
<EVCU value="USD"/>
</Data>
</Event>
<Role>
<Header>
<Action value="Create"/>
</Header>
<Key>
<QROCD value="BOR"/>
<RIENALTYNA value="TX34 CST NR"/>
<RIENALID value="501882"/>
</Key>
<Data>
<ISROPTPC value="100"/>
</Data>
</Role>
<Role>
<Header>
<Action value="Create"/>
</Header>
<Key>
<QROCD value="TAKER"/>
<RIENALTYNA value="TX34 RT NR"/>
<RIENALID value="501882"/>
</Key>
<Data>
<ISROPTPC value="100"/>
</Data>
</Role>
<Udf>
<Header>
<Action value="Create"/>
</Header>
<Key>
<UDTYNA value="LEGAL ENTITY"/>
</Key>
<Data>
<UDDA value="LEGAL ENTITY DESCRIPTION"/>
</Data>
</Udf>
</Facility>
What I'm trying to do is create a stylesheet that can extract the value attribute and but it into a text file. The Style sheet that I've created is as below:
<?xml version="1.0"?>
<xsl:stylesheet version = "1.0"
xmlns:xsl = "<xsl
utput method="text"/>
<xsl:template match="Facility">
<xsl:value-of select="/Facility/Key/BAAPID/@value"/>
<xsl:text>@value</xsl:text>
</xsl:template>
</xsl:stylesheet>
I'm trying to start small by just being able to extract one attribute - if I could even do that at least I'd be on my way to getting through this.
Any advice would be greatly appreciated. Apologies if my question appears obvious.
Thanks and regards,
Tom
I'm attempting to convert an XML document to text and I would be grateful for any advice that you may have.
I have an XML document that uses node attributes quite a lot - the attribute name is always "value" even though the tag name can differ - below is an example:
<Facility>
<Header>
<Action value="Create"/>
</Header>
<Key>
<BAAPID value="TX34"/>
<PRCD value="920431"/>
</Key>
<Data>
<ALTYNA value="TX PDT"/>
<ISTYALID value="TX34-USD-LP-F"/>
<COFL value="N"/>
</Data>
<Event>
<Header>
<Action value="Create"/>
</Header>
<Key>
<EVURRE value="limit amount"/>
</Key>
<Data>
<EVSETYNA value="LINE-EVENTS"/>
<EVTYNA value="START"/>
<EVAM value="-7000000"/>
<EVDA value="2006-05-31"/>
<EVCU value="USD"/>
</Data>
</Event>
<Event>
<Header>
<Action value="Create"/>
</Header>
<Key>
<EVURRE value="limit expiry"/>
</Key>
<Data>
<EVSETYNA value="LINE-EVENTS"/>
<EVTYNA value="END"/>
<EVAM value="0"/>
<EVDA value="2006-06-30"/>
<EVCU value="USD"/>
</Data>
</Event>
<Role>
<Header>
<Action value="Create"/>
</Header>
<Key>
<QROCD value="BOR"/>
<RIENALTYNA value="TX34 CST NR"/>
<RIENALID value="501882"/>
</Key>
<Data>
<ISROPTPC value="100"/>
</Data>
</Role>
<Role>
<Header>
<Action value="Create"/>
</Header>
<Key>
<QROCD value="TAKER"/>
<RIENALTYNA value="TX34 RT NR"/>
<RIENALID value="501882"/>
</Key>
<Data>
<ISROPTPC value="100"/>
</Data>
</Role>
<Udf>
<Header>
<Action value="Create"/>
</Header>
<Key>
<UDTYNA value="LEGAL ENTITY"/>
</Key>
<Data>
<UDDA value="LEGAL ENTITY DESCRIPTION"/>
</Data>
</Udf>
</Facility>
What I'm trying to do is create a stylesheet that can extract the value attribute and but it into a text file. The Style sheet that I've created is as below:
<?xml version="1.0"?>
<xsl:stylesheet version = "1.0"
xmlns:xsl = "<xsl
<xsl:template match="Facility">
<xsl:value-of select="/Facility/Key/BAAPID/@value"/>
<xsl:text>@value</xsl:text>
</xsl:template>
</xsl:stylesheet>
I'm trying to start small by just being able to extract one attribute - if I could even do that at least I'd be on my way to getting through this.
Any advice would be greatly appreciated. Apologies if my question appears obvious.
Thanks and regards,
Tom