xsl-list
[Top] [All Lists]

Re: Attribute and Element Formatting Issues

2005-09-14 01:49:16
Please try this stylesheet

<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
 
<xsl:output method="xml" indent="yes" /> 

<xsl:template match="node() | @*">
   <xsl:copy>
     <xsl:apply-templates select="node() | @*" />
   </xsl:copy>
</xsl:template>
 
<xsl:template match="dictionary">
   <xsl:apply-templates select="dict" />
</xsl:template>
 
<xsl:template match="dict">
   <xsl:element name="{translate(@name,' ','')}">
     <xsl:value-of select="." />
   </xsl:element>
</xsl:template>
 
</xsl:stylesheet>

Regards,
Mukul


On 9/13/05, Mehta, Chirag <chirag(_dot_)mehta(_at_)bankofamerica(_dot_)com> 
wrote:
Hi,

I am new to XSL and I have been trawling the web to find out how to
accomplish this:

<?xml version="1.0" encoding="utf-8"?>
<portfolio name="CBOT" version="1">
  <trade name="Future" quantity="1">
     <instrument instType="Bond">
        <dictionary>
           <dict name="expiry date" type="t">
           </dict>

           <dict name="strike" type="d">0.95</dict>

           <dict name="option type" type="s">EuropeanCall</dict>
        </dictionary>
     </instrument>
  </trade>
</portfolio>


TO:

<?xml version="1.0" encoding="utf-8"?>
<portfolio name="CBOT" version="1">
  <trade name="Future" quantity="1">
     <instrument instType="Bond">
        <expiryDate>
        </expiryDate>

        <strike>0.95</strike>

        <optionType>EurpoeanCall</optionType>
     </instrument>
  </trade>
</portfolio>

I have got this far:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
  <xsl:output indent="yes" />


<!--<xsl:strip-space elements="*" /> -->
  <xsl:template match="">
     <xsl:copy>

<!--<xsl:if test="@name">-->
           <xsl:for-each select="dict">
<!--<xsl:element name="{(_at_)name}"> -->
              <xsl:value-of select="." />

<!--</xsl:element> -->
           </xsl:for-each>

<!--</xsl:if> -->
     </xsl:copy>

     <xsl:apply-templates/>
  </xsl:template>
</xsl:stylesheet>

And have reached a standstill. There are issues with the attributes
having a space, not changing the element name to the attribute name etc.


Can anyone point me in the right direction?


Thanks guys,

Chigs












Notice to recipient:
The information in this internet e-mail and any attachments is confidential 
and may be privileged. It is intended solely for the addressee. If you are 
not the intended addressee please notify the sender immediately by telephone. 
If you are not the intended recipient, any disclosure, copying, distribution 
or any action taken or omitted to be taken in reliance on it, is prohibited 
and may be unlawful.

When addressed to external clients any opinions or advice contained in this 
internet e-mail are subject to the terms and conditions expressed in any 
applicable governing terms of business or client engagement letter issued by 
the pertinent Bank of America group entity.

If this email originates from the U.K. please note that Bank of America, 
N.A., London Branch, Banc of America Securities Limited and Banc of America 
Futures Incorporated are authorised and regulated by the Financial Services 
Authority.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>