Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2012, 05:14 PM
Authorized User
 
Join Date: May 2009
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default XSD namespace and xml validation issue

Hi, I have the following schema.

HTML Code:
 
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://BioArchR2_Email_Notifications_Pipeline.CustomerAck" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BioArchR2_Email_Notifications_Pipeline.CustomerAck" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="esbEvent">
    <xs:annotation>
      <xs:appinfo>
        <b:properties>
          <b:property distinguished="true" xpath="/*[local-name()='esbEvent' and namespace-uri()='http://BioArchR2_Email_Notifications_Pipeline.CustomerAck']/*[local-name()='header' and namespace-uri()='']/*[local-name()='errorNumber' and namespace-uri()='']" />
        </b:properties>
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="header">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="eventDateTime" type="xs:string" />
              <xs:element name="interfaceName" type="xs:string" />
              <xs:element name="transID" type="xs:string" />
              <xs:element name="resultCode" type="xs:string" />
              <xs:element name="errorNumber" type="xs:string" />
              <xs:element name="contentCount" type="xs:string" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="resultDescription">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="error" type="xs:string" />
              <xs:element minOccurs="0" maxOccurs="unbounded" name="warning" type="xs:string" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
 
-----------------------------
When I validate the sample given below against the schema, I get an error. The sample and error are given below.

HTML Code:
<esbEvent xmlns="http://BioArchR2_Email_Notifications_Pipeline.CustomerAck">
<header>
  <eventDateTime>01/12/2012 10:25:29 AM</eventDateTime> 
  <interfaceName>CFS.Customer</interfaceName> 
  <transID>PhoneTest20120106sg.xml01-12-2012 10:16:26.0</transID> 
  <resultCode>-1</resultCode> 
  <errorNumber>3</errorNumber> 
  <contentCount>0</contentCount> 
  </header>
<resultDescription>
  <error>Error</error> 
  <error>INTERNAL_ERROR Error</error> 
  <error>Error</error> 
</resultDescription>
 /esbEvent>
-----------------------------
Error:

The element 'esbEvent' in namespace 'http://BioArchR2_Email_Notifications_Pipeline.CustomerAck ' has invalid child element 'header' in namespace 'http://BioArchR2_Email_Notifications_Pipeline.CustomerAck '. List of possible elements expected: 'header'.

-----------------------------
Can anyone please help me with getting over this issue. I spent a day to see what is wrong and can't still figure out.
thanks in advance.
 
Old January 28th, 2012, 06:35 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Add elementFormDefault="qualified" to the xs:schema element.

This is the preferred setting in 99.9% of all cases. The language designers got the default wrong, in a silly attempt to make elements and attributes symmetric.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
spring2009 (January 29th, 2012)
 
Old January 29th, 2012, 09:22 AM
Authorized User
 
Join Date: May 2009
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default Thanks

Thanks so much. After I included elementFormDefault, it worked. Thanks again.
 
Old January 29th, 2012, 11:52 AM
Authorized User
 
Join Date: May 2009
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default Another question please xslt output not consistent

I have this XSL and input. The outputis not as I expected. The HTML formatting is missign in the resulting output file for some of the input files. Can someone please help with this?

I would have tried all combinations myself but I am really short on time and have to get this working in next few hours. any help is greatly appreciated.
Thanks a lot,

--------------------
xslt

HTML Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://BioArchR2_Email_Notifications_Pipeline.CustomerError">
<xsl:template match="/">
    <html>
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
   <title>Customer Error Report Mail</title>
   <style></style>
  </head>
  <body bgcolor="#FFFFFF">
   <!--<table border="20" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#6699FF" width="100%" id="AutoNumber1" height="336">-->
         <table border="1">
        <tr>
 
            <font face="Arial">
              <b>Customer Update Error Information is below: </b>           
            </font>
 
        </tr>
      <tr>
        <td><b>Customer Name</b></td>
 
<td><b>Customer Facility Code</b></td>
 
<td><b>Customer Department Code</b></td>
 
<td><b>Error Message</b></td>
 
<td><b>Error Type</b></td>
        </tr>
           <xsl:for-each select="//ns0:errorDetail">
      <tr>
        <td><xsl:value-of select="ns0:custName" /></td>
 
        <td><xsl:value-of select="ns0:custId" /></td>
 
        <td><xsl:value-of select="ns0:department" /></td>
 
        <td><xsl:value-of select="ns0:message" /></td>
 
        <td><xsl:value-of select="ns0:type" /></td>
      </tr>
             </xsl:for-each>
    </table>
  </body>
 </html>
</xsl:template>
</xsl:stylesheet>

-------------------
Input file
HTML Code:
<ns0:CustUpdateError xmlns:s0="http://BioArchR2_Email_Notifications_Pipeline.CustomerAck" xmlns:ns0="http://BioArchR2_Email_Notifications_Pipeline.CustomerError">
    <ns0:eventDateTime>12/08/2011 12:14:18 PM</ns0:eventDateTime>
    <ns0:interfaceName>CFS.Customer</ns0:interfaceName>
    <ns0:fileName>adf17879-b06b-42df-ad0c-d471d95ef9c4.xml12-08-2011 12:02:51.0</ns0:fileName>
    <ns0:contentCount>63</ns0:contentCount>
    <ns0:errorCount>45</ns0:errorCount>
    <ns0:errorDetail>
        <ns0:type>Warning</ns0:type>
        <ns0:custName> INTERLAKES ONCOLOGY AND HEMATOLOGY    </ns0:custName>
        <ns0:custId> 001001046a    </ns0:custId>
        <ns0:department> dept1    </ns0:department>
        <ns0:message>Invalid customer phone number    field : 585-475-8700  X1    </ns0:message>
    </ns0:errorDetail>
    <ns0:errorDetail>
        <ns0:type>Warning</ns0:type>
        <ns0:custName> ARCBS-NEW YORK-PENN REGION    </ns0:custName>
        <ns0:custId>    001001w    </ns0:custId>
        <ns0:department> dhf dept with spaces     </ns0:department>
        <ns0:message>Invalid customer phone number    field : 800-836-1992      </ns0:message>
    </ns0:errorDetail>
    <ns0:errorDetail>
        <ns0:type>Warning</ns0:type>
        <ns0:custName> SUNY UPSTATE MEDICAL UNIVERSITY    </ns0:custName>
        <ns0:custId> 001B1SUCLk    </ns0:custId>
        <ns0:department>     </ns0:department>
        <ns0:message>Invalid customer phone number    field : 315-464-4608      </ns0:message>
    </ns0:errorDetail>
    <ns0:errorDetail>
        <ns0:type>Warning</ns0:type>
        <ns0:custName> ROBERTS WESLEYAN COLLEGE    </ns0:custName>
        <ns0:custId> 001ROBWESa    </ns0:custId>
        <ns0:department>     </ns0:department>
        <ns0:message>Invalid customer phone number    field : 585-594-6485      </ns0:message>
    </ns0:errorDetail>
</ns0:CustUpdateError>

-------------Output-------
HTML Code:
<TABLE border=1>
<TBODY>
<TR><FONT face=Arial><B>Customer Update Error Information is below: </B></FONT></TR>
<TR>
<TD><B>Customer Name</B></TD>
<TD><B>Customer Facility Code</B></TD>
<TD><B>Customer Department Code</B></TD>
<TD><B>Error Message</B></TD>
<TD><B>Error Type</B></TD></TR>
<TR>
<TD>INTERLAKES ONCOLOGY AND HEMATOLOGY </TD>
<TD>001001046a </TD>
<TD>dept1 </TD>
<TD>Invalid customer phone number field : 585-475-8700 X1 </TD>
<TD>Warning</TD></TR>
<TR>
<TD>ARCBS-NEW YORK-PENN REGION </TD>
<TD>001001w </TD>
<TD>dhf dept with spaces </TD>
<TD>Invalid customer phone number field : 800-836-1992 </TD>
<TD>Warning</TD></TR>
<TR>
<TD>SUNY UPSTATE MEDICAL UNIVERSITY </TD>
<TD>001B1SUCLk </TD>
<TD></TD>
<TD>Invalid customer phone number field : 315-464-4608 </TD>
<TD>Warning</TD></TR>
<TR>
<TD>ROBERTS WESLEYAN COLLEGE </TD>
<TD>001ROBWESa </TD>
<TD></TD>
<TD>Invalid customer phone number field : 585-594-6485 </TD>
<TD>Warning</TD></TR></TBODY></TABLE>
 
Old January 29th, 2012, 02:24 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's best to start a new thread for a new question.

Which bit of the output is not as you would have expected: and what was your expectation. From a quick glance, the output is exactly what I would expect, but that's hardly surprising.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old January 29th, 2012, 05:43 PM
Authorized User
 
Join Date: May 2009
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default THANK YOU

Hi,
Thanks a lot for your response. I realized after your response that the xslt works fine. For some reason the emails went to junk folder and did not display the table. Instead displayed everything as plain text. Once I moved them to inbox they look fine. Now they go directly to my inbox. Thanks again for your prompt response. I can sleep well today(after a week).





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSD namespace and xml validation issue spring2009 XSLT 0 January 28th, 2012 05:13 PM
namespace issue. xml and xsd jamesdurham XML 5 April 7th, 2009 07:13 PM
create xml with xsd validation obaxe3k XSLT 1 August 13th, 2008 09:43 AM
XML validation with XSD ksskumar XML 0 October 12th, 2007 04:46 AM
xml validation with xsd amolkad XML 0 June 24th, 2004 06:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.