You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Bovy, Stephen J" <ST...@ca.com> on 2004/01/30 00:52:49 UTC

Imbedded "schema" with "xpointer" ??

Hi List, I am new to xml and new to this list 

Question # 1:

I have been struggling with an Idea.  

Is there any way possible to create an xml document that 
includes/im-beds its own schema within the doc, so that
I don't need to have two separate files.  I was toying with the
idea of using "xpointer", but this is problemetic because
Xerces does not support "xpointer" yet.  Does anyone know
if using xerces with xlan will give me the "xpointer" support I 
desire ??

Here is what my xml file might look like:

*****************************************************
<?xml version="1.0" encoding="utf-8" ?>
<PurchaseOrders
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="#xpointer(/schema)">

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">   

<xs:element name="PurchaseOrders">    
<xs:complexType>                       
<xs:sequence maxOccurs="unbounded">    
                                       
<xs:element name="PurchaseOrder"      
    type="rowType"/>                   
                                       
</xs:sequence>                         
</xs:complexType>                      
</xs:element>
 

<xs:complexType name="rowType">                           
<xs:sequence>                                             
                                             
<xs:element name="name"                      
    type="fieldType1"/>                      
<xs:element name="address"                   
    type="fieldType2"/>                      
<xs:element name="phonenumber"              
    type="fieldType3"/>                      
<xs:element name="partnumber"               
    type="fieldType4"/>                      
<xs:element name="quantity"                  
    type="fieldType5"/>                      
<xs:element name="price"                     
    type="fieldType6"/>                      
<xs:element name="total"                     
    type="fieldType7"/>                      
                                             
</xs:sequence>                               
</xs:complexType>                            
                                             
<xs:simpleType name="fieldType1">            
  <xs:restriction base="xs:string">          
    <xs:maxLength value="15"/>               
  </xs:restriction>                          
</xs:simpleType>                             
                                             
<xs:simpleType name="fieldType2">          
  <xs:restriction base="xs:string">        
    <xs:maxLength value="30"/>             
  </xs:restriction>                        
</xs:simpleType>                           
                                           
<xs:simpleType name="fieldType3">          
  <xs:restriction base="xs:string">        
    <xs:maxLength value="12"/>             
  </xs:restriction>                        
</xs:simpleType>                           
                                           
<xs:simpleType name="fieldType4">          
  <xs:restriction base="xs:short"/>        
</xs:simpleType>                           
                                           
<xs:simpleType name="fieldType5">          
  <xs:restriction base="xs:short"/>        
</xs:simpleType>                           
                                           
<xs:simpleType name="fieldType6">          
  <xs:restriction base="xs:decimal">       
    <xs:fractionDigits value="2"/>         
    <xs:totalDigits value="4"/>            
  </xs:restriction>                        
</xs:simpleType>                           
                                           
<xs:simpleType name="fieldType7">       
  <xs:restriction base="xs:decimal">    
    <xs:fractionDigits value="2"/>      
    <xs:totalDigits value="7"/>         
  </xs:restriction>                     
</xs:simpleType>                        
                                        
</xs:schema>

<PurchaseOrder>
  <name>Steve Bovy</name>
  <address>9399 Pali Ave</address>
  <phonenumber>818-333-9914</phonenumber>
  <partnumber> 1234</partnumber>
  <quantity>-1</quantity>
  <price>-15.41</price>
  <total>-45.32</total>
</PurchaseOrder>

<PurchaseOrder>
  <name>John Doe</name>
  <address>Never Land</address>
  <phonenumber>818-999-9999</phonenumber>
  <partnumber> 3241</partnumber>
  <quantity> 20</quantity>
  <price> 15.41</price>
  <total> 45.32</total>
</PurchaseOrder>

</PurchaseOrders>

*************************end of xml example*************** 

Question #2 forgive me I know this is a little off-topic.

I was trying to use visual studio .net 2003 to validate my xml doc
against the schema.  When I press the validate menu item, it says it
could not find the schema, but when I examine my xml doc and the schema,
it seems like everything is correct could anyone guide me tell me if my
xml files are correct ???

Here they are: (both files reside in the same "dir")

testdoc.xsd:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
                                                          
<xs:element name="PurchaseOrders">                       
<xs:complexType>                                          
<xs:sequence maxOccurs="unbounded">                       
                                                          
<xs:element name="PurchaseOrder"                         
    type="rowType"/>                                      
                                                          
</xs:sequence>                                            
</xs:complexType>                                         
</xs:element>                                             
                                                          
<xs:complexType name="rowType">                           
<xs:sequence>                                             
                                             
<xs:element name="name"                      
    type="fieldType1"/>                      
<xs:element name="address"                   
    type="fieldType2"/>                      
<xs:element name="phonenumber"              
    type="fieldType3"/>                      
<xs:element name="partnumber"               
    type="fieldType4"/>                      
<xs:element name="quantity"                  
    type="fieldType5"/>                      
<xs:element name="price"                     
    type="fieldType6"/>                      
<xs:element name="total"                     
    type="fieldType7"/>                      
                                             
</xs:sequence>                               
</xs:complexType>                            
                                             
<xs:simpleType name="fieldType1">            
  <xs:restriction base="xs:string">          
    <xs:maxLength value="15"/>               
  </xs:restriction>                          
</xs:simpleType>                             
                                             
<xs:simpleType name="fieldType2">          
  <xs:restriction base="xs:string">        
    <xs:maxLength value="30"/>             
  </xs:restriction>                        
</xs:simpleType>                           
                                           
<xs:simpleType name="fieldType3">          
  <xs:restriction base="xs:string">        
    <xs:maxLength value="12"/>             
  </xs:restriction>                        
</xs:simpleType>                           
                                           
<xs:simpleType name="fieldType4">          
  <xs:restriction base="xs:short"/>        
</xs:simpleType>                           
                                           
<xs:simpleType name="fieldType5">          
  <xs:restriction base="xs:short"/>        
</xs:simpleType>                           
                                           
<xs:simpleType name="fieldType6">          
  <xs:restriction base="xs:decimal">       
    <xs:fractionDigits value="2"/>         
    <xs:totalDigits value="4"/>            
  </xs:restriction>                        
</xs:simpleType>                           
                                           
<xs:simpleType name="fieldType7">       
  <xs:restriction base="xs:decimal">    
    <xs:fractionDigits value="2"/>      
    <xs:totalDigits value="7"/>         
  </xs:restriction>                     
</xs:simpleType>                        
                                        
</xs:schema>

testdoc.xml:

<?xml version="1.0" encoding="utf-8" ?>
<PurchaseOrders
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="testdoc.xsd">
	<PurchaseOrder>
		<name>Steve Bovy</name>
		<address>9399 Pali Ave</address>
		<phonenumber>818-223-9916</phonenumber>
		<partnumber> 1234</partnumber>
		<quantity>-1</quantity>
		<price>-15.41</price>
		<total>-45.32</total>
	</PurchaseOrder>
	<PurchaseOrder>
		<name>John Doe</name>
		<address>Never Land</address>
		<phonenumber>818-999-9999</phonenumber>
		<partnumber> 3241</partnumber>
		<quantity> 20</quantity>
		<price> 15.41</price>
		<total> 45.32</total>
	</PurchaseOrder>
</PurchaseOrders>

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org