NOEL ALEX MAKUMULI schrieb am 29.04.2009 um 01:45:03 (+0300):
> 
> hello Michael,
> thanks for the quick and nice suggestions..

Hi Noel,

you're welcome.

> well i have to say that the issue which you have pointed out is the
> nine namespaces which some have no use..i asked the same question..
> 
> the issue which i am trying to achieve is to get the individual string
> value like status and language code..
> 
> if i remember correctly when i was doing transformation from one XMlL
> format to another XML format....like shown below:
> <Root>
> <child>child</child>
> </Root>
> the XSL transformation is pretty easy: <xsl:value-of
> select="/Root/child"> and will get the output child---

<xsl:value-of> gets the string value; <xsl:copy-of> copies the node.

> the issue is that the SOAP which comes has a lot of information which
> i really do not need... and i would like to use XSL to filter this
> information and remain with the few data which i would use..

Start out with the so-called "identity transform":

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

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

As step 1, run the transform, and look at the result to see the effect.
Then add the following rules one by one and repeat step 1 each time
around.

Add parsing and serialization instructions to get clean input and
output:

  <xsl:strip-space elements="*"/><!-- for parsing -->
  <xsl:output indent="yes"/><!-- for serialization -->

Replace the document element:

  <xsl:template match="/*"><!-- document element -->
    <Root>
      <xsl:apply-templates select="*"/>
    </Root>
  </xsl:template>

Replace the cmn:state element, and here, you need to add the namespace
to the stylesheet, and if you don't want it in the output, then you
exclude it:

<xsl:stylesheet version="1.0"
  xmlns:cmn="http://www.companyName.com/XMLSchema/compMain.xsd";
  exclude-result-prefixes="cmn"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:template match="cmn:state">
    <child><xsl:apply-templates/></child>
  </xsl:template>

Final touch, add a rule to filter out everything else:

  <xsl:template match="*" priority="-0.4">
    <xsl:apply-templates select="*"/>
  </xsl:template>

> :-) i am not an expert in XSL and XML ...
> when i said normal XML file i meant the one which has root doctype..
> 
> i have tried the <xsl:copy-of> and this is the sample result::
> <soap_message><cmn:responseStatus
> xmlns:fs="http://www.asiakastieto.fi/XMLSchema/FinancialStatementCompany_4.03.xsd";
> xmlns:pr="http://www.asiakastieto.fi/XMLSchema/PopulationInformation_4.00.xsd";>
> 1</cmn:responseStatus></soap_message>
> 
> is there any possible way to remove the namesapces here and have
> something clean like::
> <Root>
> 
> <child>child</child>
> 
> </Root>

See above.

> i am certainly heading to Mulberrytech.com ..
> 
> could you please suggest some nice readings of XSL and XSL
> namespaces..because i would like to learn more about this now..

Namespaces are just a mapping from prefixes to URIs (well, strings).
Not much to say. For XSLT, there are good sites and books:

* http://www.jenitennison.com/
* http://www.dpawson.co.uk/xsl/
* books by Jeni Tennison, Michael Kay, Evan Lenz, others

I hope this helps :-)

Michael Ludwig

Reply via email to