Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Still having problem with namespace

From: "Marrow" <m--a-r-r-o-w@--------------------.--->
To: NULL
Date: 10/1/2004 12:26:00 AM
Hi Tanya,

It works with the example input you gave... therefore...

Be aware that namespaces are macthed/selected based upon the URI (and as
with almost all things XML - case-sensitive!)- so you need to check the
namespace URI declared in your stylesheet is the same namespace URI as the
one declared in your input XML, e.g.

if your input XML looks like...

 <inputroot>
    <abc>
 <outputroot xmlns="www.xyz-whatever.com">
 <a>
 <a1> A1 data </a1>
 </a>
 <b>
 <b1> B1 data </b1>
 </b>
 </outputroot>
    </abc>
    <def>
 <c>data3</c>
    </def>
 </inputroot>

then the namespace declared in the stylesheet needs to match that URI, e.g.

<xsl:stylesheet version="1.0" exclude-result-prefixes="in"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:in="www.xyz-whatever.com"
  xmlns="www.trial.com">


Cheers
Marrow


"Tanya" <anonymous@d...> wrote in message
news:212d01c4a6e7$6a2f2fb0$a601280a@p......
> Thanks but unfortunately, that doesnt solve my problem. It
> still lists only the root node in the output doc as:
> <outputroot xmlns="www.trial.com">
> </outputroot>
> This is all I get.
>
> >-----Original Message-----
> >Hi Tanya,
> >
> >You will need to declare a namespace (with a prefix) in
> your stylesheet so
> >that you can select and match against the nodes in your
> input document that
> >are bound to the default namespace, e.g. something like...
> >
> ><?xml version="1.0"?>
> ><xsl:stylesheet version="1.0" exclude-result-prefixes="in"
> >  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >  xmlns:in="www.trial.com"
> >  xmlns="www.trial.com">
> >
> ><xsl:template match="/">
> >  <outputroot>
> >    <xsl:apply-templates
> select="inputroot/abc/in:outputroot/in:a" />
> >    <xsl:apply-templates
> select="inputroot/abc/in:outputroot/in:b" />
> >  </outputroot>
> ></xsl:template>
> >
> ><xsl:template match="in:a">
> >  <!-- stuff here -->
> >  <xsl:comment>This shows the template matched the <a>
> >element</xsl:comment>
> ></xsl:template>
> >
> ><xsl:template match="in:b">
> >  <!-- stuff here -->
> >  <xsl:comment>This shows the template matched the <b>
> >element</xsl:comment>
> ></xsl:template>
> >
> ></xsl:stylesheet>
> >
> >
> >HTH
> >Marrow
> >http://www.marrowsoft.com - home of Xselerator (XSLT IDE
> and debugger)
> >http://www.topxml.com/Xselerator
> >
> >
> >"Tanya" <anonymous@d...> wrote in
> message
> >news:092301c4a6d3$988f60a0$a301280a@p......
> >> Hi,
> >>
> >> I seem to be getting nowhere with namespaces.
> >> Well, the specs have changed and my problem has taken a
> >> different shape.
> >>
> >> Let me reiterate what I have to do.  I have to transform
> >> an input xml doc to an output xml doc.
> >>
> >> This is my input xml doc:
> >>
> >> <inputroot>
> >>    <abc>
> >> <outputroot xmlns="www.trial.com">
> >> <a>
> >> <a1> A1 data </a1>
> >> </a>
> >> <b>
> >> <b1> B1 data </b1>
> >> </b>
> >> </outputroot>
> >>    </abc>
> >>    <def>
> >> <c>data3</c>
> >>    </def>
> >> </inputroot>
> >>
> >>
> >> This has to be transformed as:
> >>
> >> <outputroot xmlns="www.trial.com">
> >> <a>
> >> <a1> A1 data </a1>
> >> </a>
> >> <b>
> >> <b1> B1 data </b1>
> >> </b>
> >> </outputroot>
> >>
> >> The main portion of my XSL:
> >>
> >> <xsl:template match="/">
> >> <xsl:element name="outputroot">
> >> <xsl:apply-templates
> >> select="inputroot/abc/outputroot/a" />
> >> <xsl:apply-templates
> >> select="inputroot/abc/outputroot/b" />
> >> </xsl:element>
> >> </xsl:template>
> >>
> >> <xsl:template match="a">
> >>   <!-- stuff here -->
> >> </xsl:template>
> >>
> >> <xsl:template match="b">
> >>   <!-- stuff here -->
> >> </xsl:template>
> >>
> >> This xsl gives me the output document with only
> >> <outputroot> node. If I remove the namespace declaration
> >> from "outputroot" in the input document, it seems to
> work
> >> fine.
> >> My aim is to get the default namespace in "outputroot"
> out
> >> on the output document as well. I think Iam missing
> >> something in the template match condition.
> >>
> >> Can somebody help me?
> >>
> >> thanks.
> >>
> >
> >
> >.
> >




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent