OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

ubl-dev message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: Validating UBL examples with xmllint


At 2004-05-20 18:30 +0100, Pedro Alves wrote:
>On Thu, May 20, 2004 at 07:04:03PM +0300, G. Ken Holman wrote:
> >
> > XSLT and XPath questions would be better posted to the following list:
> >
> >   http://www.mulberrytech.com/xsl/xsl-list
> >
>
>
>     I know this is not the most correct place, but please answer me one
>more, since it is a practical example.

I do not mind at all, Pedro, as it is my profession to teach and consult in 
XML to worldwide clients, and indeed you are now asking these questions in 
the context of UBL I'm hoping the others on UBL-Dev will not find this out 
of scope.

>     I had my ubl Orders.xml beginning with <Order>.
>
>     In order to be precise, I changed the XML so that suns msv validates the
>file.

Why did MSV not validate the file before?  Oh, had you omitted the 
namespace declarations before?

>I know have:
>
><Order xmlns="urn:oasis:names:tc:ubl:Order:1:0"
>xmlns:cac="urn:oasis:names:tc:ubl:CommonAggregateComponents:1:0"
>xmlns:cbc="urn:oasis:names:tc:ubl:CommonBasicComponents:1:0" 
>xmlns:cur="urn:oasis:names:tc:ubl:codelist:CurrencyCode:1:0" 
>xmlns:res="urn:oasis:names:tc:ubl:codelist:AcknowledgementResponseCode:1:0" 
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
>xsi:schemaLocation="urn:oasis:names:tc:ubl:Order:1:0 
>../../xsd/maindoc/UBL-Order-1.0.xsd">
>   <BuyersID>EW112429145</BuyersID>
>   <cbc:IssueDate>2004-01-17</cbc:IssueDate>
>.....
>
>
>However, my xls stylesheets stoped working.
>
>I made a few surfing and changed:
>
>     <xsl:template match="Order">

Ahhhhhhh, yes, the dreaded default namespace problem. :{)}

>to
>
>     <xsl:template match="{urn:oasis:names:tc:ubl:Order:1:0}Order">

That is not the correct notation, but you do now understand what you need.

>But still gives errors.
>
>How can I handle this?

By declaring a namespace in your stylesheet and then using that explicitly.

The rule in XPath 1.0 is that the default namespace is *never* used in 
XPath expressions, so by saying match="Order" you are matching Order in no 
namespace.

Do the following using any namespace you wish to use:

    <xsl:stylesheet ....
         xmlns:pedro="urn:oasis:names:tc:ubl:Order:1:0}Order"
         xmlns:ken="urn:oasis:names:tc:ubl:CommonBasicComponents:1:0">

      <xsl:template match="pedro:Order">
        .....

      <xsl:template match="pedro:Order/ken:IssueDate">
        .....

Note that as editor of the UBL FPSC Formatting Specifications, I made sure 
that *every* XPath address in the formatting specifications used the 
appropriate namespace for every step; check out the example here:

   http://docs.oasis-open.org/ubl/cd-UBL-1.0/fs/Order/UN220Order.html#buyer

Remember that namespace prefixes are arbitrary, not standardized (which is 
why I'm allowed to use our names as prefixes), but as a *convention* the 
entire UBL TC adopted the following set of namespace prefixes to use for 
documentary purposes only:

  xmlns:cac="urn:oasis:names:tc:ubl:CommonAggregateComponents:1:0
  xmlns:cbc="urn:oasis:names:tc:ubl:CommonBasicComponents:1:0
  xmlns:ccts="urn:oasis:names:tc:ubl:CoreComponentParameters:1:0
  xmlns:rt="urn:oasis:names:tc:ubl:RepresentationTerms:1:0"
  xmlns:da="urn:oasis:names:tc:ubl:DespatchAdvice:1:0"
  xmlns:in="urn:oasis:names:tc:ubl:Invoice:1:0"
  xmlns:po="urn:oasis:names:tc:ubl:Order:1:0"
  xmlns:xo="urn:oasis:names:tc:ubl:OrderCancellation:1:0"
  xmlns:co="urn:oasis:names:tc:ubl:OrderChange:1:0"
  xmlns:ro="urn:oasis:names:tc:ubl:OrderResponse:1:0"
  xmlns:rs="urn:oasis:names:tc:ubl:OrderResponseSimple:1:0"
  xmlns:ra="urn:oasis:names:tc:ubl:ReceiptAdvice:1:0"

I documented this convention to LCSC here:

   http://lists.oasis-open.org/archives/ubl-lcsc/200306/msg00077.html

I hope this helps.

........................... Ken

--
Public courses: Spring 2004 world tour of hands-on XSL instruction
Next: 3-day XSLT/XPath; 2-day XSL-FO - Birmingham, UK June 14,2004

World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/u/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/u/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]