This is a problem with xpath more then xquery really ... xpath doesn't
work so great with non-prefixed namespaces.

In any case the solution is

 

                return $record//*:list

 

Note that this will match ANY namespace list element, which in your case
is fine, but in the general case is not.

I dont know of a way in xpath to match "the non prefixed namespace"
without pulling in ALL namespaces

 

 

-David

 

----------------------------------------

David A. Lee

Senior Principal Software Engineer

Epocrates, Inc.

d...@epocrates.com

812-482-5224

 

 

 

 

From: general-boun...@developer.marklogic.com
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Tim
Meagher
Sent: Thursday, March 11, 2010 10:17 PM
To: 'General Mark Logic Developer Discussion'
Subject: RE: [MarkLogic Dev General]
Probleminsertingdefaultnamespaceincreated XML document fixed,but
validation fails

 

Hi Geert, et al,

 

I'm still having a little problem.  I can construct the new document
node so that the default namespace is appropriately applied to the root
element, e.g.

For example, the contents of the newly created $record variable include
the following:

 

  <record xmlns="http://mystuff.com/schema";>

    <list>

      <item>shoes</item>

    </list>

  </record>

 

So if I write the xquery expression:

 

   return $record        

 

it will return the contents above, but if I write the xquery expression:

 

    return $record//list

 

it will return nothing.  I think this is because it needs to be aware of
the namespace, but I cannot declare the default element namespace
without confusing the construction of the $record node. How do I go
about referencing the list element within $record node without declaring
the default element namespace?

 

Thank you!

 

Tim Meagher

 

________________________________

From: general-boun...@developer.marklogic.com
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Tim
Meagher
Sent: Saturday, March 06, 2010 7:26 PM
To: 'General Mark Logic Developer Discussion'
Subject: RE: [MarkLogic Dev General] Problem
insertingdefaultnamespaceincreated XML document fixed, but validation
fails

 

Hi Geert,

 

I was receiving neither of these errors.  As it turns out, I had
neglected to use the QName to create the root element (I was fashioning
it separately from the rest of the nodeset in my code), even though one
of the attributes was the xmlns reference (which is why I thought it
wouldn't have a problem).

 

Thank you for your help!

 

Tim

 

-----Original Message-----
From: general-boun...@developer.marklogic.com
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Geert
Josten
Sent: Thursday, March 04, 2010 2:39 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Problem inserting
defaultnamespaceincreated XML document fixed, but validation fails

 

Hi Tim,

 

If the schema is not found, an XDMP-UNDSCHMAT will be thrown. If the
namespace doesn't match the one in the schema, an XDMP-SCHMNSMISMATCH is
thrown.

 

What result are you expecting and what are you getting?

 

Kind regards,

Geert

 

> -----Original Message-----

> From: general-boun...@developer.marklogic.com 

> [mailto:general-boun...@developer.marklogic.com] On Behalf Of 

> Tim Meagher

> Sent: donderdag 4 maart 2010 19:10

> To: 'General Mark Logic Developer Discussion'

> Subject: RE: [MarkLogic Dev General] Problem inserting 

> default namespaceincreated XML document fixed, but validation fails

> 

> Tried it with no success.  I'm not sure if it is adequately 

> locating the schema.

> 

>  

> 

> ________________________________

> 

> From: general-boun...@developer.marklogic.com 

> [mailto:general-boun...@developer.marklogic.com] On Behalf Of 

> Geert Josten

> Sent: Thursday, March 04, 2010 1:01 PM

> To: General Mark Logic Developer Discussion

> Subject: RE: [MarkLogic Dev General] Problem inserting 

> default namespaceincreated XML document fixed, but validation fails

> 

>  

> 

> Hi Tim,

> 

>  

> 

> Just add the following:

> 

>  

> 

> import schema "http://mystuff.com/schema"; at "/the-schema.xsd";

> 

>  

> 

> Kind regards,

> 

> Geert

> 

>  

> 

>     

> ________________________________

> 

> 

>     From: general-boun...@developer.marklogic.com 

> [mailto:general-boun...@developer.marklogic.com] On Behalf Of 

> Tim Meagher

>     Sent: donderdag 4 maart 2010 18:49

>     To: 'General Mark Logic Developer Discussion'

>     Subject: RE: [MarkLogic Dev General] Problem inserting 

> default namespace increated XML document fixed, but validation fails

> 

>     Hi Geert,

> 

>      

> 

>     This time I'm actually specifying a namespace as in the 

> XML that gets created in the example below, e.g. 

> 

>      

> 

>     <record xsi:schemaLocation="/the-schema.xsd" id="1001"

> 

>          xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

> 

>          xmlns="http://mystuff.com/schema";>

> 

>       <list>

> 

>          <item>

> 

>            ...

> 

>      

> 

>     Where "the-schema.xsd" is loaded in the root of the 

> Schemas database.

> 

>      

> 

>     I'm looking for validation syntax and trying to see if 

> I need to declare the targetNamespace in the schema.  I just 

> can't get this puppy to validate!

> 

>      

> 

>     Thanks!

> 

>      

> 

>     Tim

> 

>      

> 

>     -----Original Message-----

>     From: general-boun...@developer.marklogic.com 

> [mailto:general-boun...@developer.marklogic.com] On Behalf Of 

> Geert Josten

>     Sent: Thursday, March 04, 2010 12:21 PM

>     To: General Mark Logic Developer Discussion

>     Subject: RE: [MarkLogic Dev General] Problem inserting 

> default namespace increated XML document fixed, but validation fails

> 

>      

> 

>     Hi Tim,

> 

>      

> 

>     I looked into that earlier. To summarize this is what you need:

> 

>      

> 

>           declare default element namespace "";

> 

>           import schema "" at "/my-schema.xsd";

> 

>      

> 

>           validate strict {

> 

>                 $mydoc

> 

>           }

> 

>      

> 

>     More details can be found here 

> http://markmail.org/message/qauezioxxmyp64kd, comments from 

> Mary on the same thread may also interest you..

> 

>      

> 

>     Kind regards,

> 

>     Geert

> 

>      

> 

>     > -----Original Message-----

> 

>     > From: general-boun...@developer.marklogic.com 

> 

>     > [mailto:general-boun...@developer.marklogic.com] On Behalf Of 

> 

>     > Tim Meagher

> 

>     > Sent: donderdag 4 maart 2010 18:12

> 

>     > To: 'General Mark Logic Developer Discussion'

> 

>     > Subject: RE: [MarkLogic Dev General] Problem inserting 

> 

>     > default namespace in created XML document fixed, but 

> validation fails

> 

>     > 

> 

>     > Hi Geert,

> 

>     > 

> 

>     >  

> 

>     > 

> 

>     > Thanks for the info.  The thing that helped me most was using 

> 

>     > the QName function when creating the elements.  I thought 

> 

>     > this would fix a problem I'm having with validating content 

> 

>     > using a default namespace and schema location, but that's not 

> 

>     > the case.  I could use an example of using marklogic to 

> 

>     > validate an xml file against a schema where the xml document 

> 

>     > only contains the default namespace declaration.  That 

> 

>     > includes making sure the schema is configured correctly and 

> 

>     > that the appropriate declarations exists in the xquery code.  

> 

>     > The schema is loaded in the Schemas database.

> 

_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

Reply via email to