[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Fwd: Namespace prefixes in Schemas

Subject: Fwd: Namespace prefixes in Schemas
From: "António Mota" <amsmota@xxxxxxxxx>
Date: Wed, 16 Aug 2006 10:35:04 +0100
placeholder prefix problem
I received a strange error message in reply to my last post so i'm
reposting it, sorry for any inconvenience...

2006/8/16, Antsnio Mota <amsmota@xxxxxxxxx>:
Are you sure of that? Are you sayng that the target, not the prefix,
is cheked by the processor?

My problem is that i'm using Sarissa to get some Schema nodes using
XPath, like this

var nodes = xmlSchema.selectNodes("//xs:element");

after declaring

Sarissa.setXpathNamespaces(xmlSchema,
'xmlns:xs="http://www.w3.org/2001/XMLSchema"');

It seems that this is about the same situation you've pointed in your
answer, but that is not working, afaict it only works if the Schema
has

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

but not if it's

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">


Anyhow i'm going to try this in a XSLT "per se", not in Sarissa, to see if it works and if it works i'll check with the guys at Sarissa (if Manos don4t answer to this post first).

Thanks for your answer, it didn't solve my problem but it pointed me
to right direction, i think...





2006/8/16, Abel Online <abel.online@xxxxxxxxx>:
> Hi Antsnio,
>
> The prefix is a placeholder for the namespace. In your case, the
> namespace is http://www.w3.org/2001/XMLSchema. It does not matter what
> prefix is used in the XML document. To make sure XSL understands the
> same namespace, all you have to do is put the following in your
> stylesheet declaration:
>
> <xsl:stylesheet version="1.0"
>     xmlns:yourprefix="http://www.w3.org/2001/XMLSchema"
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> This namespace can now be used in you XPaths. This works for both 1.0
> and 2.0 XSLT. It does not matter what prefix you use. If, for instance,
> the source XML looks like this (I assume you want to parse an XMLSchema
> document):
>
>     <?xml version="1.0" encoding="UTF-8"?>
>     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
>
> you can reference elements inside this schema like this:
>
>    <xsl:value-of select="//yourprefix:simpleType" />
>
> to get all simpleType elements from the source. These will be visible
> like "xs:simpleType" in the source document. If you want to remove the
> prefixes to the output stream, you can expand the opening element of the
> xslt as follows:
>
> <xsl:stylesheet version="1.0"
>     exclude-result-prefixes="yourprefix xsl"
>     xmlns:yourprefix="http://www.w3.org/2001/XMLSchema"
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> But this is not guaranteed to work always because of the "namespace
> fixup process" at the end of the XSLT transformation.
>
> Cheers,
>
> Abel Braaksma
> http://www.nuntia.nl
>
>
> Antsnio Mota wrote:
>
> > Hello all:
> >
> > It's been a while since i don't work with XML, so bear with me if this
> > is a stupid question...
> >
> > Isaw several Schemas that have the xs namespace, like
> >
> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> >
> > and then the elements and type are referenced as
> >
> > <xs:element name="Titulo" type="xs:string"/>
> >
> > But i also saw the same thing with
> >
> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> >
> > <xsd:element name="Titulo" type="xsd:string"/>
> >
> > and others with
> >
> > <schema xmlns="http://www.w3.org/2001/XMLSchema">
> >
> > <element name="Titulo" type="string"/>
> >
> > My problem is that i'm transforming a schema in something else, and i
> > need to access some nodes with XPath expression, like
> >
> > //elements
> >
> > to access all the elements of the Schema
> >
> > So how can i know what is the prefix that a random Schena is using, or
> > how can i access nodes independently of their prefixes?
> >
> >
> > Thanks all.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.