• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xml namespace and xsl transformation problem

 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a xml file and it looks like this:
<?xml version="1.0"?>
<?CMFToolkit version="v4.9"?>
<InstrumentMessageContainer xmln="com.ubs.cmf.cmm.v2_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="I1">
<dataContainer xsi:type="InstrumentDataContainer" id="I2">
etc ......
when I use xsl to parse it, xmln="com.ubs.cmf.cmm.v2_1" will cause problem. If I change xmln="com.ubs.cmf.cmm.v2_1" to xmlnw="com.ubs.cmf.cmm.v2_1" it works fine.
My naive xsl looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates select="InstrumentMessageContainer"/>
</xsl:template>

<xsl:template match="InstrumentMessageContainer">
<InstrumentMessageContainer xmlns:xsi="{@xmlns:xsi}">
<xsl:apply-templates select="dataContainer"/>
</InstrumentMessageContainer>
</xsl:template>

<xsl:template match="dataContainer">
<dataContainer xsi:type="{@type}" id="{@id}">
<xsl:apply-templates select="issue"/>
</dataContainer>
</xsl:template>
<xsl:template match="issue">
<issue xsi:type="Issue" id="I3">
<xsl:apply-templates select="instrumentId"/>
<xsl:apply-templates select="issueType"/>

<xsl:for-each select="issueDescriptions">
<issueDescriptions xsi:type="IssueDescriptions" id="{@id}">
<xsl:apply-templates select="descriptionUsage"/>
<xsl:apply-templates select="issueName"/>
</issueDescriptions>
</xsl:for-each>
<xsl:for-each select="marketIssueCharacteristics[financialMarket='XNYS']
| marketIssueCharacteristics[financialMarket='XASE']
| marketIssueCharacteristics[financialMarket='XNAS']">
<marketIssueCharacteristics xsi:type="MarketIssueCharacteristics" id="{@id}">
<xsl:apply-templates select="tradingStatus"/>
<xsl:apply-templates select="marketIssueCharOid"/>
<xsl:apply-templates select="tradingCurrency"/>
<xsl:apply-templates select="primaryTradingMarket"/>
<xsl:apply-templates select="financialMarket"/>
</marketIssueCharacteristics>
</xsl:for-each>

<xsl:for-each select="issueIdentifiers[financialMarket='XNYS']
| issueIdentifiers[financialMarket='XASE']
| issueIdentifiers[financialMarket='XNAS']">
<issueIdentifiers xsi:type="issueIdentifiers" id="{@id}">
<xsl:apply-templates select="issueId"/>
<xsl:apply-templates select="issueIdentifierOid"/>
<xsl:apply-templates select="issueIdContext"/>
<xsl:apply-templates select="financialMarket"/>
</issueIdentifiers>
</xsl:for-each>

<xsl:for-each select="issuer">
<xsl:copy-of select="."/>
</xsl:for-each>

</issue>
</xsl:template>

<xsl:template match="instrumentId">
<instrumentId>
<xsl:value-of select="."/>
</instrumentId>
</xsl:template>

<xsl:template match="issueType">
<issueType>
<xsl:value-of select="."/>
</issueType>
</xsl:template>

<xsl:template match="descriptionUsage">
<descriptionUsage>
<xsl:value-of select="."/>
</descriptionUsage>
</xsl:template>
<xsl:template match="issueName">
<issueName>
<xsl:value-of select="."/>
</issueName>
</xsl:template>
<xsl:template match="tradingStatus">
<tradingStatus>
<xsl:value-of select="."/>
</tradingStatus>
</xsl:template>
<xsl:template match="marketIssueCharOid">
<marketIssueCharOid>
<xsl:value-of select="."/>
</marketIssueCharOid>
</xsl:template>
<xsl:template match="tradingCurrency">
<tradingCurrency>
<xsl:value-of select="."/>
</tradingCurrency>
</xsl:template>
<xsl:template match="primaryTradingMarket">
<primaryTradingMarket>
<xsl:value-of select="."/>
</primaryTradingMarket>
</xsl:template>

<xsl:template match="financialMarket">
<financialMarket>
<xsl:value-of select="."/>
</financialMarket>
</xsl:template>
<xsl:template match="issueId">
<issueId>
<xsl:value-of select="."/>
</issueId>
</xsl:template>
<xsl:template match="issueIdentifierOid">
<issueIdentifierOid>
<xsl:value-of select="."/>
</issueIdentifierOid>
</xsl:template>

<xsl:template match="issueIdContext">
<issueIdContext>
<xsl:value-of select="."/>
</issueIdContext>
</xsl:template>
<xsl:template match="searchName">
<searchName>
<xsl:value-of select="."/>
</searchName>
</xsl:template>

<!-- <xsl:template match="nationalityCountryCode ">
<nationalityCountryCode >
<xsl:value-of select="."/>
</nationalityCountryCode >
</xsl:template> -->

</xsl:stylesheet>
If you know what is wrong, please help.
reply
    Bookmark Topic Watch Topic
  • New Topic