Re: [xsl] XPath 1.0 challenge: select all XML Schema element declarations with type string

Subject: Re: [xsl] XPath 1.0 challenge: select all XML Schema element declarations with type string
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 19 Jul 2015 21:59:31 -0000
And here is a general example xsd schema on which to evaluate the
XPath 2.0 expression in the previous message:

<schema xmlns="http://www.w3.org/2001/XMLSchema";
xmlns:ab="http://www.w3.org/2001/XMLSchema";>
 <element name="shipto">
  <complexType>
   <sequence>
    <element name="name" type="string"/>
    <ab:element name="address" type="string"/>
    <element name="city" type="ab:string"/>
    <element name="country" type="string"/>
   </sequence>
  </complexType>
 </element>
</schema>

On Sun, Jul 19, 2015 at 2:32 PM, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> I believe that in its most general form this problem doesn't have a
> pure XPath 1.0 solution (though it is easy if we are allowed to use
> XSLT 1.0).
>
> We either need the feature of range variables, or the feature of being
> able to specify a function call as the last location step in a path
> expression.
>
> Here is one XPath 2.0 expression (only the last line of the last
> predicate uses XPath 2.0 (the call to name() in the ending location
> step):
>
>
>      //*[local-name()='element' and
> namespace-uri()='http://www.w3.org/2001/XMLSchema'
>        and
>           (
>            @type[. = 'string'
>                  and (//namespace::*[. =
> 'http://www.w3.org/2001/XMLSchema' and not(name())])
>          or translate(.,
> '_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', '')=':'
>                  and substring-after(., ':') = 'string'
>                  and not(substring(.,1,1) = ':')
>                  and substring-before(., ':') = //namespace::*[. =
> 'http://www.w3.org/2001/XMLSchema']/name()
>                 ]
>           )
>         ]
>
> On Sun, Jul 19, 2015 at 12:58 PM, Costello, Roger L.
> costello@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>> Hi Folks,
>>
>> The following XPath expression returns all XML Schema element declarations with @type equal to xs:string:
>>
>>         //xs:element[@type = 'xs:string']
>>
>> However, that XPath assumes the schema file is written with a namespace prefix, like this:
>>
>>         <xs:element name="Test" type="xs:string" />
>>
>> But the schema file could have been written like this:
>>
>>         <element name="Test" type="string" />
>>
>> The above XPath expression would fail to return that element declaration.
>>
>> Is there a way -- in XPath 1.0 -- to write an XPath expression which returns all element declarations of type string?
>>
>> /Roger
>> 
>
>
>
> --
> Cheers,
> Dimitre Novatchev
> ---------------------------------------
> Truly great madness cannot be achieved without significant intelligence.
> ---------------------------------------
> To invent, you need a good imagination and a pile of junk
> -------------------------------------
> Never fight an inanimate object
> -------------------------------------
> To avoid situations in which you might make mistakes may be the
> biggest mistake of all
> ------------------------------------
> Quality means doing it right when no one is looking.
> -------------------------------------
> You've achieved success in your field when you don't know whether what
> you're doing is work or play
> -------------------------------------
> To achieve the impossible dream, try going to sleep.
> -------------------------------------
> Facts do not cease to exist because they are ignored.
> -------------------------------------
> Typing monkeys will write all Shakespeare's works in 200yrs.Will they
> write all patents, too? :)
> -------------------------------------
> Sanity is madness put to good use.
> -------------------------------------
> I finally figured out the only reason to be alive is to enjoy it.



-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

Current Thread