You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Vanessa D Johnson <va...@jpl.nasa.gov> on 2001/03/28 02:43:43 UTC
Redirect and top element namespaces in an xml file
I have an xml file of type:
<foo>
<foo-bar>
<bar></bar>
</foo-bar>
<foo-bar>
<bar></bar>
</foo-bar>
</foo>
And use redirection mechanisms to output two different files and it works
fine.
The minute I include namespaces in the root element foo, such that <foo>
now becomes
<foo xmlns = "http://myurl" xmlns:xsi =
"http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation =
"http://myschemaLoc" xmlns:other = "http://myOtherSchema" xmlns:xlink =
"http://www.w3.org/1999/xlink">
I am not able to redirect to two output files.
I am using the xalan example
java org.apache.xalan.xslt Process -IN -XSL etc...
Thanks,
Vanessa Johnson
Vanessa D. Johnson
Advanced Mission Software Technology Group
Mission Execution and Automation - Section 368
Jet Propulsion Laboratory
voice: (818) 354-3885
Re: Redirect and top element namespaces in an xml file
Posted by Vanessa D Johnson <va...@jpl.nasa.gov>.
At 3/28/2001 10:23 AM, you wrote:
>Vanessa D Johnson wrote:
> >
> > Thanks Gary -
> >
> > Is there another way to leave the default namespace,
> > xmlns="http://guadanini/arch/xArch/mdstypes.xsd", but not have to prefix
> > every element? In xml schema there is the notion of elementFormDefault and
> > attributeFormDefault so prefixing does not have to be required. Is there
> > an equivalent of that for xsl?
> >
> > Vanessa
>
>I don't believe so but Joe K is probably the expert on this. Perhaps
>he'll be able to help.
>
>Gary
How do I get in touch with Joe K?
Vanessa
Vanessa D. Johnson
Advanced Mission Software Technology Group
Mission Execution and Automation - Section 368
Jet Propulsion Laboratory
voice: (818) 354-3885
Re: node-set() extension function
Posted by Gary L Peskin <ga...@firstech.com>.
Alex Reuter wrote:
>
> Gary,
> Thanks for correctly guessing I meant to say the node-set() extension
> function. My mistake.
>
> Are you sure XalanJ1 has the function? Is there anywhere you know of that I
> could get this implementation?
>
> Thanks Again!
> Alex
It comes with XalanJ1. Check out the source downloaded with the
distribution. I would -strongly- advise upgrading to XalanJ2 though.
Gary
RE: node-set() extension function
Posted by Alex Reuter <ar...@monsterdaata.com>.
Gary,
Thanks for correctly guessing I meant to say the node-set() extension
function. My mistake.
Are you sure XalanJ1 has the function? Is there anywhere you know of that I
could get this implementation?
Thanks Again!
Alex
-----Original Message-----
From: Gary L Peskin [mailto:garyp@firstech.com]
Sent: Wednesday, March 28, 2001 1:46 PM
To: xalan-dev@xml.apache.org
Subject: Re: node-list() extension function
Alex Reuter wrote:
>
> Hello List,
> I was wondering if any version of xalan has the node-list() extension
> function similair to the one in saxon?
>
> thanks,
> Alex
Both XalanJ1 and XalanJ2 offer a nodeset extension function.
http://xml.apache.org/xalan-j/extensionslib.html#nodeset
Gary
Re: node-list() extension function
Posted by Gary L Peskin <ga...@firstech.com>.
Alex Reuter wrote:
>
> Hello List,
> I was wondering if any version of xalan has the node-list() extension
> function similair to the one in saxon?
>
> thanks,
> Alex
Both XalanJ1 and XalanJ2 offer a nodeset extension function.
http://xml.apache.org/xalan-j/extensionslib.html#nodeset
Gary
node-list() extension function
Posted by Alex Reuter <ar...@monsterdaata.com>.
Hello List,
I was wondering if any version of xalan has the node-list() extension
function similair to the one in saxon?
thanks,
Alex
Re: Redirect and top element namespaces in an xml file
Posted by Gary L Peskin <ga...@firstech.com>.
Vanessa D Johnson wrote:
>
> Thanks Gary -
>
> Is there another way to leave the default namespace,
> xmlns="http://guadanini/arch/xArch/mdstypes.xsd", but not have to prefix
> every element? In xml schema there is the notion of elementFormDefault and
> attributeFormDefault so prefixing does not have to be required. Is there
> an equivalent of that for xsl?
>
> Vanessa
I don't believe so but Joe K is probably the expert on this. Perhaps
he'll be able to help.
Gary
Re: Redirect and top element namespaces in an xml file
Posted by Vanessa D Johnson <va...@jpl.nasa.gov>.
Thanks Gary -
Is there another way to leave the default namespace,
xmlns="http://guadanini/arch/xArch/mdstypes.xsd", but not have to prefix
every element? In xml schema there is the notion of elementFormDefault and
attributeFormDefault so prefixing does not have to be required. Is there
an equivalent of that for xsl?
Vanessa
At 3/27/2001 05:41 PM, you wrote:
>Vanessa --
>
>Your XPath pattern match="foo/foo-bar" is not matching anything. When
>you do not supply a namespace prefix in a stylesheet, it is treated as
>if the elements are not in a namespace (XPath section 2.3). However, in
>your XML document, you supply a default namespace with your
>
> xmlns="http://guadanini/arch/xArch/mdstypes.xsd"
>
>namespace declaration. So, for your XML document, all unprefixed
>elements are treated as if they are in this default namespace. So, your
>elements in the default namespace will never match elements that are not
>in a namespace.
>
>To remedy this, change your xsl:stylesheet element to:
>
><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0"
> xmlns:lxslt="http://xml.apache.org/xslt"
> xmlns:redirect="org.apache.xalan.lib.Redirect"
> xmlns:x="http://guadanini/arch/xArch/mdstypes.xsd"
> extension-element-prefixes="redirect">
>
>You don't have to use "x". You can use any prefix you want since its
>the URI that matters and not the prefix. Then, change your xsl:template
>element to:
>
> <xsl:template match="x:foo/x:foo-bar">
>
>Everything should start working again.
>
>Also, note that the default namespace does not apply to attributes so
>your @name will still work as is.
>
>HTH,
>Gary
>
>
>Vanessa D Johnson wrote:
> >
> > At 3/27/2001 04:55 PM, you wrote:
> > >Vanessa D Johnson wrote:
> > > >
> > > > I have an xml file of type:
> > > >
> > > > <foo>
> > > > <foo-bar>
> > > > <bar></bar>
> > > > </foo-bar>
> > > > <foo-bar>
> > > > <bar></bar>
> > > > </foo-bar>
> > > > </foo>
> > > >
> > > > And use redirection mechanisms to output two different files and it
> works
> > > > fine.
> > > >
> > > > The minute I include namespaces in the root element foo, such that
> <foo>
> > > > now becomes
> > > >
> > > > <foo xmlns = "http://myurl" xmlns:xsi =
> > > > "http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation =
> > > > "http://myschemaLoc" xmlns:other = "http://myOtherSchema" xmlns:xlink =
> > > > "http://www.w3.org/1999/xlink">
> > > >
> > > > I am not able to redirect to two output files.
> >
> > >What happens? Do you get an error? Empty output?
> >
> > I do not get an error. The output files are not created.
> >
> > >This will be very hard to diagnose unless you can provide a copy of your
> > >XSLT stylesheet and actual XML input that will allow us to recreate the
> > >problem.
> >
> > <?xml version="1.0"?>
> >
> > <foo xmlns = "http://guadanini/arch/xArch/mdstypes.xsd" xmlns:xlink
> > ="http://www.w3.org/1999/xlink">
> > <foo-bar name="foo-bar">
> > <bar>
> > <bar-foo>bar-foo</bar-foo>
> > </bar>
> > </foo-bar>
> >
> > <foo-bar name="foo-bar-00">
> > <bar>
> > <bar-foo>bar-foo-00</bar-foo>
> > </bar>
> > </foo-bar>
> > </foo>
> >
> > <?xml version='1.0' encoding='utf-8' ?>
> >
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > version="1.0"
> > xmlns:lxslt="http://xml.apache.org/xslt"
> > xmlns:redirect="org.apache.xalan.lib.Redirect"
> > extension-element-prefixes="redirect"><xsl:output method="xml"
> > indent="yes"/>
> >
> > <xsl:template match="foo/foo-bar">
> > <redirect:write select="@name">
> > <foo>
> > <name><xsl:value-of select="@name"/></name>
> > </foo>
> > </redirect:write>
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> > Take out xmlns : namespace in <foo> element and the files are created
> again.
> >
> > Vanessa
> >
> > Vanessa D. Johnson
> > Advanced Mission Software Technology Group
> > Mission Execution and Automation - Section 368
> > Jet Propulsion Laboratory
> > voice: (818) 354-3885
Vanessa D. Johnson
Advanced Mission Software Technology Group
Mission Execution and Automation - Section 368
Jet Propulsion Laboratory
voice: (818) 354-3885
Re: Redirect and top element namespaces in an xml file
Posted by Gary L Peskin <ga...@firstech.com>.
Vanessa --
Your XPath pattern match="foo/foo-bar" is not matching anything. When
you do not supply a namespace prefix in a stylesheet, it is treated as
if the elements are not in a namespace (XPath section 2.3). However, in
your XML document, you supply a default namespace with your
xmlns="http://guadanini/arch/xArch/mdstypes.xsd"
namespace declaration. So, for your XML document, all unprefixed
elements are treated as if they are in this default namespace. So, your
elements in the default namespace will never match elements that are not
in a namespace.
To remedy this, change your xsl:stylesheet element to:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:redirect="org.apache.xalan.lib.Redirect"
xmlns:x="http://guadanini/arch/xArch/mdstypes.xsd"
extension-element-prefixes="redirect">
You don't have to use "x". You can use any prefix you want since its
the URI that matters and not the prefix. Then, change your xsl:template
element to:
<xsl:template match="x:foo/x:foo-bar">
Everything should start working again.
Also, note that the default namespace does not apply to attributes so
your @name will still work as is.
HTH,
Gary
Vanessa D Johnson wrote:
>
> At 3/27/2001 04:55 PM, you wrote:
> >Vanessa D Johnson wrote:
> > >
> > > I have an xml file of type:
> > >
> > > <foo>
> > > <foo-bar>
> > > <bar></bar>
> > > </foo-bar>
> > > <foo-bar>
> > > <bar></bar>
> > > </foo-bar>
> > > </foo>
> > >
> > > And use redirection mechanisms to output two different files and it works
> > > fine.
> > >
> > > The minute I include namespaces in the root element foo, such that <foo>
> > > now becomes
> > >
> > > <foo xmlns = "http://myurl" xmlns:xsi =
> > > "http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation =
> > > "http://myschemaLoc" xmlns:other = "http://myOtherSchema" xmlns:xlink =
> > > "http://www.w3.org/1999/xlink">
> > >
> > > I am not able to redirect to two output files.
>
> >What happens? Do you get an error? Empty output?
>
> I do not get an error. The output files are not created.
>
> >This will be very hard to diagnose unless you can provide a copy of your
> >XSLT stylesheet and actual XML input that will allow us to recreate the
> >problem.
>
> <?xml version="1.0"?>
>
> <foo xmlns = "http://guadanini/arch/xArch/mdstypes.xsd" xmlns:xlink
> ="http://www.w3.org/1999/xlink">
> <foo-bar name="foo-bar">
> <bar>
> <bar-foo>bar-foo</bar-foo>
> </bar>
> </foo-bar>
>
> <foo-bar name="foo-bar-00">
> <bar>
> <bar-foo>bar-foo-00</bar-foo>
> </bar>
> </foo-bar>
> </foo>
>
> <?xml version='1.0' encoding='utf-8' ?>
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0"
> xmlns:lxslt="http://xml.apache.org/xslt"
> xmlns:redirect="org.apache.xalan.lib.Redirect"
> extension-element-prefixes="redirect"><xsl:output method="xml"
> indent="yes"/>
>
> <xsl:template match="foo/foo-bar">
> <redirect:write select="@name">
> <foo>
> <name><xsl:value-of select="@name"/></name>
> </foo>
> </redirect:write>
> </xsl:template>
>
> </xsl:stylesheet>
>
> Take out xmlns : namespace in <foo> element and the files are created again.
>
> Vanessa
>
> Vanessa D. Johnson
> Advanced Mission Software Technology Group
> Mission Execution and Automation - Section 368
> Jet Propulsion Laboratory
> voice: (818) 354-3885
Re: Redirect and top element namespaces in an xml file
Posted by Vanessa D Johnson <va...@jpl.nasa.gov>.
At 3/27/2001 04:55 PM, you wrote:
>Vanessa D Johnson wrote:
> >
> > I have an xml file of type:
> >
> > <foo>
> > <foo-bar>
> > <bar></bar>
> > </foo-bar>
> > <foo-bar>
> > <bar></bar>
> > </foo-bar>
> > </foo>
> >
> > And use redirection mechanisms to output two different files and it works
> > fine.
> >
> > The minute I include namespaces in the root element foo, such that <foo>
> > now becomes
> >
> > <foo xmlns = "http://myurl" xmlns:xsi =
> > "http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation =
> > "http://myschemaLoc" xmlns:other = "http://myOtherSchema" xmlns:xlink =
> > "http://www.w3.org/1999/xlink">
> >
> > I am not able to redirect to two output files.
>What happens? Do you get an error? Empty output?
I do not get an error. The output files are not created.
>This will be very hard to diagnose unless you can provide a copy of your
>XSLT stylesheet and actual XML input that will allow us to recreate the
>problem.
<?xml version="1.0"?>
<foo xmlns = "http://guadanini/arch/xArch/mdstypes.xsd" xmlns:xlink
="http://www.w3.org/1999/xlink">
<foo-bar name="foo-bar">
<bar>
<bar-foo>bar-foo</bar-foo>
</bar>
</foo-bar>
<foo-bar name="foo-bar-00">
<bar>
<bar-foo>bar-foo-00</bar-foo>
</bar>
</foo-bar>
</foo>
<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:redirect="org.apache.xalan.lib.Redirect"
extension-element-prefixes="redirect"><xsl:output method="xml"
indent="yes"/>
<xsl:template match="foo/foo-bar">
<redirect:write select="@name">
<foo>
<name><xsl:value-of select="@name"/></name>
</foo>
</redirect:write>
</xsl:template>
</xsl:stylesheet>
Take out xmlns : namespace in <foo> element and the files are created again.
Vanessa
Vanessa D. Johnson
Advanced Mission Software Technology Group
Mission Execution and Automation - Section 368
Jet Propulsion Laboratory
voice: (818) 354-3885
Re: Redirect and top element namespaces in an xml file
Posted by Gary L Peskin <ga...@firstech.com>.
Vanessa D Johnson wrote:
>
> I have an xml file of type:
>
> <foo>
> <foo-bar>
> <bar></bar>
> </foo-bar>
> <foo-bar>
> <bar></bar>
> </foo-bar>
> </foo>
>
> And use redirection mechanisms to output two different files and it works
> fine.
>
> The minute I include namespaces in the root element foo, such that <foo>
> now becomes
>
> <foo xmlns = "http://myurl" xmlns:xsi =
> "http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation =
> "http://myschemaLoc" xmlns:other = "http://myOtherSchema" xmlns:xlink =
> "http://www.w3.org/1999/xlink">
>
> I am not able to redirect to two output files.
What happens? Do you get an error? Empty output?
This will be very hard to diagnose unless you can provide a copy of your
XSLT stylesheet and actual XML input that will allow us to recreate the
problem.
Gary