xsl-list
[Top] [All Lists]

Re: [xsl] XML Schema 1.0 files

2013-03-27 08:28:19

A partial answer

using xmlsh

xpath -i abc.xsd "//xsd:attribute[@name='x']/ancestor::xsd:schema/@targetNamespace"

Delivers the associated namespace when a match is found.


regards



On 27/03/13 11:58, davep wrote:
On 27/03/13 11:34, Wolfgang Laun wrote:
I think I did something similar only recently. My XML schema had
attributes marking the "interesting" xsd:element (and xsd:attribute)
definitions. Based on this I created a key with the names of the
marked elements.

<xsl:key name="kSkips"
          match="element()[@my:mark='1']"
          use="@name"/>

Key lookup uses name() to identify an "interesting" element in the XML.

-W

I'm querying a set of files (cmd line, via xmlsh) so I don't have
a list of names

Basically they are all interesting?

Thanks Wolfgang

DaveP




On 27/03/2013, davep <davep(_at_)dpawson(_dot_)co(_dot_)uk> wrote:
On 27/03/13 10:56, Philip Fearon wrote:
I haven't done this myself (and I may be missing something obvious),
but have you tried using the XPath 2.0 fn:resolve-QName() function
(http://www.w3.org/TR/xpath-functions/#func-resolve-QName) ?

The xs:QName result of this function can then be used as the argument
for fn:namespace-uri-from-QName() to return the namespace URI.

Phil Fearon


I think not Phil?
net.sf.saxon.s9api.SaxonApiException: Function resolve-QName() must have
2 arguments

I want to query with a localname only?
This because the element may be in any one of a number of namespaces?

Thanks for the suggestion though.

regards



On Wed, Mar 27, 2013 at 10:14 AM, davep <davep(_at_)dpawson(_dot_)co(_dot_)uk> 
wrote:
Given an XML schema, I want to find files containing definitions &
references  of a particular element

Root is

<xsd:schema xmlns="http://www.x";
          targetNamespace="http://www.x";
    ...

Later I see

<xsd:element ref="X"/>

and

<xsd:element name="X">
but also
<xsd:element ref="dc:X"/>


I'm looking for some xslt 2.0 that will combine
them to search for element X definitions and references
and report their namespace.
I'm working on a directory, so I'll be using collection() but
for one file all I want to know is
if element X (ref or def) is in the  file, and if so, what the
appropriate
namespace is.
So the stylesheet parameters are the localname and the
returned value either nothing (not found) or the namespace in which
the
element is, indicating it was found?
AFAICT in the above example, the namespace is
/xsd:schema/@targetNamespace

Has anyone done this before please?

TiA

regards

--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--






regards

--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--






regards




regards

--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--