Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Still having problem with namespace >Thread Next - Re: Still having problem with namespace Re: Still having problem with namespaceTo: 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.
> >>
> >
> >
> >.
> >
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
