wow thanks ! I didnt know you could do that.

Declare a prefix for a namespace to query  a non-prefixed document
without changing the document.

 

I had to try it to prove to myself it worked.

Does.

extra cool.

 

 

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Keith L.
Breinholt
Sent: Thursday, March 11, 2010 11:48 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev
General]Probleminsertingdefaultnamespaceincreated XML document fixed,but
validation fails

 

You can declare a prefix for a namespace and use it in XQuery or XPath
like this:

 

declare namespace mystuff = "http://mystuff.com/schema";;

 

$record//mystuff:list

Try it out.

 

Keith L. Breinholt

[email protected]

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Lee, David
Sent: Thursday, March 11, 2010 9:36 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General]
Probleminsertingdefaultnamespaceincreated XML document fixed, but
validation fails

 

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.

[email protected]

812-482-5224

 

 

 

 

From: [email protected]
[mailto:[email protected]] 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: [email protected]
[mailto:[email protected]] 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: [email protected]
[mailto:[email protected]] 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: [email protected] 

> [mailto:[email protected]] 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: [email protected] 

> [mailto:[email protected]] 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: [email protected] 

> [mailto:[email protected]] 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: [email protected] 

> [mailto:[email protected]] 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: [email protected] 

> 

>     > [mailto:[email protected]] 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.

> 



NOTICE: This email message is for the sole use of the intended
recipient(s) and may contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.

 

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to