Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation Putting an image source in XML

    Hi all,

    I'm new to XML so I hope you guys can bear with me if the questions are simple.

    I'm trying to put in an image source in XML-DTD. Below are the codings that I have input(I have simplified the codes to my error instead of putting the whole chunk in). But when I tried validating at http://validator.w3.org/check I'm getting errors.

    I know that when I input <img src> it is an xhtml, however that is not what I want. I only want it kept within XML-DTD.

    Please advise or can someone illustrate via another example?

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    		
    <!DOCTYPE information [
    
    	<!ELEMENT information (biography+, jobtype)>
    	
      	<!ELEMENT biography (images)>
    	<!ELEMENT images (#PCDATA)>
    	<!ATTLIST images img src CDATA #REQUIRED>
                 ...
    		
    ]>
    
    <information>
        <biography>
    	<images src>
    	<img src="pictures/doctor/doctor4.jpg" />
    	</images src>
    
                 .....
         </biography>
    	
    	
    </information>

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE information [
    	<!ELEMENT information (biography+, jobtype)>
      	<!ELEMENT biography (images)>
    	<!ELEMENT images (#PCDATA)>
    	<!ATTLIST images img src CDATA #REQUIRED>
                 ...
    		
    ]>
    
    <information>
        <biography>
    	<images src>
    	<img src="pictures/doctor/doctor4.jpg" />
    	</images src>
    
                 .....
         </biography>
    	
    	
    </information>
    - dots could be a cause, but I guess you don't have this in the source you try to validate. You can't have text between tags something like:
    Code:
    <element1>
    </element1>
    text here is invalid
    <element2>
    </element2>
    - src if is attribute must be src="something" or if you want to express that is about image source you can use a proper tag name like <image-source> or something else.

    This is as far I test it valid, but you must change some multiplicators, must be probably biography+ instead of biography and so on.
    Code:
    <?xml encoding="UTF-8"?>
    <!DOCTYPE information [
    <!ELEMENT information (biography)>
    <!ATTLIST information
      xmlns CDATA #FIXED ''>
    
    <!ELEMENT biography (images)>
    <!ATTLIST biography
      xmlns CDATA #FIXED ''>
    
    <!ELEMENT images (img)>
    <!ATTLIST images
      xmlns CDATA #FIXED ''>
    
    <!ELEMENT img EMPTY>
    <!ATTLIST img
      xmlns CDATA #FIXED ''
      src CDATA #REQUIRED>
    ]>
    <information>
        <biography>
    	<images>
    	<img src="pictures/doctor/doctor4.jpg" />
    	</images>
         </biography>
    </information>
    best regards

  • Users who have thanked oesxyl for this post:

    thesaint (10-22-2008)

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    oesxyl, I manage edit to fit my scenario and validate it.

    Appreciate the help.

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by thesaint View Post
    oesxyl, I manage edit to fit my scenario and validate it.

    Appreciate the help.
    I'm glad you solve it.
    A better solution is to design schema for your xml using relax ng.

    http://www.relaxng.org/

    then you can convert using for example trang to what you need, dtd or else.
    relax ng help a lot with validation so you can validate against a rnc or rng schema instead of dtd.

    best regards


  •  

    Posting Permissions

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