Results 1 to 11 of 11

Thread: xsd Node Question

  1. #1

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    xsd Node Question

    Hey all,

    is it possible to declare that all content of a node is only seen as text till that node ends?

    So that an xml document like this

    Code:
    <Data>myText</Data>
    and a document like this

    Code:
    <Data><myNewDoc></myNewDoc></Data>
    would both be valid and could be parsed against one Schema?

    Thanks,

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  2. #2
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    Sheesh how frustrating! I battled with that for SOOOO long! Anyway, here she is:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    	<xs:element name="data">
    		<xs:annotation>
    			<xs:documentation>Comment describing your root element</xs:documentation>
    		</xs:annotation>
    		<xs:complexType mixed="true">
    			<xs:sequence>
    				<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>
    </xs:schema>

  3. #3

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Unhappy

    How did you test it?

    I always get an error message saying

    C:\test\test_element.xml Could not find schema information for the element 'myNewDoc'. An error occurred at file:///C:/test/test_element.xml, (2, 8).

    So it validates the one with only text but not the one with another element in it.

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    If you want the "inner element" to be parsed as pure text, you can use a CDATA node:
    Code:
    <outer><![CDATA[<inner></inner>]]></outer>
    The inner element won't be parsed, you'll get it as a literal string.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Unhappy

    Sorry, still the same error.
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Exactly the same? Then the parser is buggy...

    Which parser do you use?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    I am doing the validation in Microsofts BizTalk Server 2004. So it should be MSXML right?
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  8. #8
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    Let me check it again. But I am pretty sure it worked.

  9. #9
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    I used xml spy to validate the documents.
    The one with just a node:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!--Sample XML file generated by XML Spy v4.4 U (http://www.xmlspy.com)-->
    <data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="E:\DayneO\My Documents\Business Associates\DPO Solutions\Examples\node_with_any_child.xsd">
    	<myNewDoc></myNewDoc>
    </data>
    The one with just text:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!--Sample XML file generated by XML Spy v4.4 U (http://www.xmlspy.com)-->
    <data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="E:\DayneO\My Documents\Business Associates\DPO Solutions\Examples\node_with_any_child.xsd">
    	text
    </data>

  10. #10
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    Post your xml document and schema so I can see the exact structure.

  11. #11

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    I'll post it tomorrow, when I am back in work!
    Thanx all,

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width