Link to home
Start Free TrialLog in
Avatar of Mani Pazhana
Mani PazhanaFlag for United States of America

asked on

XSLT Parsing Error

I am getting this error:

Schema validation error at LineNumber: [1], LinePosition: [421], Message: [The element 'CriticalDateFields' in namespace 'http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1' has invalid child element 'SquareArea' in namespace 'http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1'. List of possible elements expected: 'CriticalDateValue' in namespace 'http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1'.], SourceSchemaObject: [], SourceUri: []


Here is my XSLT:


<?xml version="1.0" encoding="UTF-8"?>

<!--  Event Mapping (For Horizon to CIM)
          VERSION :           V1
          INITIAL DATE:                        08/14/2013
          LAST UPDATED DATE:       08/22/2013      
      Created By:         Mani
      -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1"
    xmlns:common="http://integration.cbre.com/schemas/gcs/common/v1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
    version="1.0" >

  <xsl:output indent="yes"/>

  <xsl:template match="batch">
    <Lease xmlns="http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1"
           xmlns:common="http://integration.cbre.com/schemas/gcs/common/v1"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <xsl:apply-templates select="row"/>
    </Lease>
  </xsl:template>

  <xsl:template match="row">
    <ClientId>HP</ClientId>
   
    <LeaseId>
      <xsl:value-of select="LeaseID"/>
    </LeaseId>
   
    <CriticalDates>
      <CriticalDateFields>
        <CriticalDateId>
          <xsl:value-of select="EventSequenceNumber"/>
        </CriticalDateId>
       
        <CriticalDateType>
          <common:Code>
            <xsl:value-of select="LeaseEventTypeID"/>
          </common:Code>
          <common:Description>
            <xsl:value-of select="LeaseEventTypeID"/>
          </common:Description>
        </CriticalDateType>

        <xsl:if test="NotificationDate">
          <CriticalDateValue>
            <xsl:call-template name="normalize-date">
              <xsl:with-param name="date" select="NotificationDate"/>
            </xsl:call-template>
          </CriticalDateValue>
        </xsl:if>

        <SquareArea>3.14E0</SquareArea>
       
        <SquareAreaUOM>
          <common:Code>SQFT</common:Code>
          <common:Description>SQFT</common:Description>
        </SquareAreaUOM>

        <xsl:if test="EffectiveDate">
          <EffectiveDate>
            <xsl:call-template name="normalize-date">
              <xsl:with-param name="date" select="EffectiveDate"/>
            </xsl:call-template>
          </EffectiveDate>
        </xsl:if>
       
        <xsl:if test="EventComment">
          <Comments>
            <xsl:value-of select="EventComment"/>
          </Comments>
        </xsl:if>
       
        <CriticalDateStatus>
          <common:Code>Active</common:Code>
          <common:Description>Active</common:Description>
        </CriticalDateStatus>
       
      </CriticalDateFields>
    </CriticalDates>

  </xsl:template>

  <xsl:template name="normalize-date">
    <xsl:param name="date"/>
    <xsl:value-of select="format-number(number(substring-after(substring-after($date, '/'), '/')), '0000')"/>
    <xsl:text>-</xsl:text>
    <xsl:value-of select="format-number(number(substring-before(substring-after($date, '/'), '/')), '00')"/>
    <xsl:text>-</xsl:text>
    <xsl:value-of select="format-number(number(substring-before($date, '/')), '00')"/>
    <xsl:text>T00:00:00Z</xsl:text>
  </xsl:template>
</xsl:stylesheet>



Here is my Input XML:

<batch>    
  <row>
    <LeaseID>10004</LeaseID>
    <EventSequenceNumber>4</EventSequenceNumber>
    <LeaseEventTypeID>4</LeaseEventTypeID>
    <EffectiveDate>15/03/2012</EffectiveDate>
    <EventComment>Notification Begin Date: 03/15/2011 At the end of the Lease, it may be extended for yearly periods by the Tenant to a maximum of 5 years. If the Tenant does not wish to extend the Lease, it must given written notice to the Landlord 2 months in advance of the end of the lease. If notice is not served, the Lease will renew automatically.</EventComment>
  </row>
</batch>


Any idea?
Avatar of Mani Pazhana
Mani Pazhana
Flag of United States of America image

ASKER

Here is my XSD:

<?xml version="1.0" encoding="utf-8"?>
<!-- edited with XMLSpy v2013 rel. 2 sp2 (http://www.altova.com) by Amy Force (CB Richard Ellis Services, Inc) -->
<xs:schema xmlns="http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:common="http://integration.cbre.com/schemas/gcs/common/v1" targetNamespace="http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1" elementFormDefault="qualified">
      <!--  LEASE CRITICAL DATES
      VERSION : V1
      INITIAL DATE:                               08/12/2013
      LAST UPDATED DATE:       08/12/2013      BY: AForce
      
      V1 - Amy Force - Initial version of the CIM Lease Critical Dates XSD (based on Leae v1.4) - minimum critical date information only

      -->
      <!-- Include -->
      <xs:import namespace="http://integration.cbre.com/schemas/gcs/common/v1" schemaLocation="integration.cbre.com.schemas.gcs.common.v1.xsd"/>
      <!-- XSD -->
      <xs:complexType name="CriticalDateFields">
            <xs:annotation>
                  <xs:documentation>Critical Date</xs:documentation>
            </xs:annotation>
            <xs:sequence>
                  <xs:element name="CriticalDateId" type="xs:int" minOccurs="0">
                        <xs:annotation>
                              <xs:documentation>The ID for this Critical Date (if available)</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="CriticalDateType" type="common:Codes" nillable="true" minOccurs="1">
                        <xs:annotation>
                              <xs:documentation>Indicates the type of critical date</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="CriticalDateValue" type="xs:dateTime" nillable="true">
                        <xs:annotation>
                              <xs:documentation>Based on the type of option, the critical date value should contain the date that the user wants to use to track this option as being completed on time against.  It might be the Action Date, Landlord Notice Date, or the Effective Date.</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="SquareArea" type="xs:double">
                        <xs:annotation>
                              <xs:documentation>Lease Area (in unit of measure provided in 'Square Area Unit of Measure') </xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="SquareAreaUOM" type="common:Codes">
                        <xs:annotation>
                              <xs:documentation>The unit of measure for area indicated in the Square Area</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="ActionDate" type="xs:dateTime" minOccurs="0">
                        <xs:annotation>
                              <xs:documentation>Date that the account team has specified that they want to have completed a decision on the option. Use ISO 8601 DateTime as standard [YYYY-MM-DDThh:mm:ss]</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="EffectiveDate" type="xs:dateTime">
                        <xs:annotation>
                              <xs:documentation>The date that the option would come in to effect if actioned.  Also referred to as Date of Option or Effective Start Date.Use ISO 8601 DateTime as standard [YYYY-MM-DDThh:mm:ss]</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="CompletedDate" type="xs:dateTime" minOccurs="0">
                        <xs:annotation>
                              <xs:documentation>Completed Date.  Use ISO 8601 DateTime as standard [YYYY-MM-DDThh:mm:ss]</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="CurrentExpirationDate" type="xs:dateTime" minOccurs="0">
                        <xs:annotation>
                              <xs:documentation>Date of current lease expiration. Use ISO 8601 DateTime as standard [YYYY-MM-DDThh:mm:ss]</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="LandlordNoticeDate" type="xs:dateTime" minOccurs="0">
                        <xs:annotation>
                              <xs:documentation>The last date to serve any notice required to trigger the option. Use ISO 8601 DateTime as standard [YYYY-MM-DDThh:mm:ss]</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="OptionEndDate" type="xs:dateTime" minOccurs="0">
                        <xs:annotation>
                              <xs:documentation>The date the option would end e.g. the last day of a specific renewal period. Please enter the "Date of Option" date if the option is a one off event e.g. break option.  Also referred to as the Effective End Date, or Date Option ceases. Use ISO 8601 DateTime as standard [YYYY-MM-DDThh:mm:ss]</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="NewEndDate" type="xs:dateTime" minOccurs="0">
                        <xs:annotation>
                              <xs:documentation>New expiration date (if the lease has been extended, etc). Use ISO 8601 DateTime as standard [YYYY-MM-DDThh:mm:ss]</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="Comments" type="xs:string" minOccurs="0">
                        <xs:annotation>
                              <xs:documentation>A comment related to this Critical Date</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="CriticalDateStatus" type="common:Codes" minOccurs="0">
                        <xs:annotation>
                              <xs:documentation>Indicates the current status of the critical date</xs:documentation>
                        </xs:annotation>
                  </xs:element>
            </xs:sequence>
      </xs:complexType>
      <xs:complexType name="LeaseDetails">
            <xs:annotation>
                  <xs:documentation>Details of the lease (non-financial)</xs:documentation>
            </xs:annotation>
            <xs:sequence>
                  <xs:element name="ClientId" type="xs:string" nillable="true">
                        <xs:annotation>
                              <xs:documentation>Unique Client identifier</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="LeaseId" type="xs:string" nillable="true">
                        <xs:annotation>
                              <xs:documentation>Unique Lease ID used by the client as identification (this may or may not be the same as the system ID)</xs:documentation>
                        </xs:annotation>
                  </xs:element>
                  <xs:element name="CriticalDates" type="ArrayOfCriticalDates" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
      </xs:complexType>
      <xs:complexType name="ArrayOfCriticalDates">
            <xs:annotation>
                  <xs:documentation>List of Critical Dates</xs:documentation>
            </xs:annotation>
            <xs:sequence>
                  <xs:element name="CriticalDateFields" type="CriticalDateFields" minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                              <xs:documentation>Critical Dates associated with this lease</xs:documentation>
                        </xs:annotation>
                  </xs:element>
            </xs:sequence>
      </xs:complexType>
      <xs:element name="Lease" type="LeaseDetails" nillable="true"/>
</xs:schema>
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. That error went off..now another error...


Schema validation error at LineNumber: [1], LinePosition: [481], Message: [The 'http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1:CriticalDateValue' element is invalid - The value 'NaN-NaN-NaNT00:00:00Z' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:dateTime' - The string 'NaN-NaN-NaNT00:00:00Z' is not a valid DateTime value.], SourceSchemaObject: [], SourceUri: []


Schema validation error at LineNumber: [1], LinePosition: [1026], Message: [The 'http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1:Comments' element is invalid - The value 'Notification Begin Date: 03/15/2011 At the end of the Lease, it may be extended for yearly periods by the Tenant to a maximum of 5 years. If the Tenant does not wish to extend the Lease, it must given written notice to the Landlord 2 months in advance of the end of the lease. If notice is not served, the Lease will renew automatically.' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:dateTime' -




The string 'Notification Begin Date: 03/15/2011 At the end of the Lease, it may be extended for yearly periods by the Tenant to a maximum of 5 years. If the Tenant does not wish to extend the Lease, it must given written notice to the Landlord 2 months in advance of the end of the lease. If notice is not served, the Lease will renew automatically.' is not a valid DateTime value.], SourceSchemaObject: [], SourceUri: []



Here is my XSLT:

<?xml version="1.0" encoding="UTF-8"?>

<!--  Event Mapping (For Horizon to CIM)
          VERSION :           V1
          INITIAL DATE:                        08/14/2013
          LAST UPDATED DATE:       08/22/2013      
      Created By:         Mani
      -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1"
    xmlns:common="http://integration.cbre.com/schemas/gcs/common/v1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
    version="1.0" >

  <xsl:output indent="yes"/>

  <xsl:template match="batch">
    <Lease xmlns="http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1"
           xmlns:common="http://integration.cbre.com/schemas/gcs/common/v1"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <xsl:apply-templates select="row"/>
    </Lease>
  </xsl:template>

  <xsl:template match="row">
    <ClientId>HP</ClientId>
   
    <LeaseId>
      <xsl:value-of select="LeaseID"/>
    </LeaseId>
   
    <CriticalDates>
      <CriticalDateFields>
        <CriticalDateId>
          <xsl:value-of select="EventSequenceNumber"/>
        </CriticalDateId>
       
        <CriticalDateType>
          <common:Code>
            <xsl:value-of select="LeaseEventTypeID"/>
          </common:Code>
          <common:Description>
            <xsl:value-of select="LeaseEventTypeID"/>
          </common:Description>
        </CriticalDateType>
       
          <CriticalDateValue>
            <xsl:call-template name="normalize-date">
              <xsl:with-param name="date" select="NotificationDate"/>
            </xsl:call-template>
          </CriticalDateValue>      

        <SquareArea>0.00</SquareArea>
               
        <SquareAreaUOM>
          <common:Code>SQFT</common:Code>
          <common:Description>SQFT</common:Description>
        </SquareAreaUOM>

        <xsl:if test="EffectiveDate">
          <EffectiveDate>
            <xsl:call-template name="normalize-date">
              <xsl:with-param name="date" select="EffectiveDate"/>
            </xsl:call-template>
          </EffectiveDate>
        </xsl:if>
       
        <xsl:if test="EventComment">
          <Comments>
            <xsl:value-of select="EventComment"/>
          </Comments>
        </xsl:if>
       
        <CriticalDateStatus>
          <common:Code>Active</common:Code>
          <common:Description>Active</common:Description>
        </CriticalDateStatus>
       
      </CriticalDateFields>
    </CriticalDates>

  </xsl:template>

  <xsl:template name="normalize-date">
    <xsl:param name="date"/>
    <xsl:value-of select="format-number(number(substring-after(substring-after($date, '/'), '/')), '0000')"/>
    <xsl:text>-</xsl:text>
    <xsl:value-of select="format-number(number(substring-before(substring-after($date, '/'), '/')), '00')"/>
    <xsl:text>-</xsl:text>
    <xsl:value-of select="format-number(number(substring-before($date, '/')), '00')"/>
    <xsl:text>T00:00:00Z</xsl:text>
  </xsl:template>
</xsl:stylesheet>
Never mind:

Here is my Input XML:

<?xml version="1.0" encoding="utf-8"?>
<batch>
  <row>
    <LeaseID>10004</LeaseID>
    <EventSequenceNumber>3</EventSequenceNumber>
    <LeaseEventTypeID>3</LeaseEventTypeID>
    <NotificationDate>17/06/2010</NotificationDate>
    <EffectiveDate>15/07/2010</EffectiveDate>
    <EventComment>Tenant may termiante the Lease</EventComment>
  </row>
</batch>


error i am getting:

Schema validation error at LineNumber: [1], LinePosition: [718], Message: [The 'http://integration.cbre.com/schemas/gcs/leasecriticaldates/v1:Comments' element is invalid - The value 'Tenant may termiante the Lease' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:dateTime' - The string 'Tenant may termiante the Lease' is not a valid DateTime value.], SourceSchemaObject: [], SourceUri: []


Any idea?
Take them one at the time, the first one is obvious, your date normalization template is not working well and returning NaN instead of numbers, so you need to plug in one of the other date processing templates

The second is weird, since you seem to have changed the schema. It complains because the Comments is not dateTime... but my version of the schema says it should be xs:string
we found out the issue...

Schema conflict…Both Notification Date and Effective Date are mandatory fields on the schema…
weird message in that case
Thanks