www.webdeveloper.com
Results 1 to 3 of 3

Thread: New to dtd & xml help

  1. #1
    Join Date
    Apr 2013
    Posts
    3

    New to dtd & xml help

    Hi there,

    I'm trying to code a cookbook, I've done the XML for a recipe but am really struggling to get the correct DTD valid.

    Any help would be MASSIVELY appreciated for a noob. Eventually the DTD and XML will have two recipes, hence why there is mention of recipetwo in the DTD.

    I keep facing errors such as document element does not allow element 'ingredient' here.
    Also error element "prep_ingredient" undefined.

    Like I said, any help would be appreciated for a beginner. Thanks!!

    This is the DTD so far followed by the XML
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE cookbook [
    <!ELEMENT cookbook (frontcover+,body+)>
    <!ELEMENT frontcover (title,byline,author)>
    <!ELEMENT title (#PCDATA)>
    <!ELEMENT byline (#PCDATA)>
    <!ELEMENT author (#PCDATA)>
    <!ELEMENT body (recipeone+,recipetwo+)>
    <!ENTITY PUBLISHER "Quadrille Publishing">
    <!ENTITY COPYRIGHT "Copyright 2010 Quadrille Publishing">

    <!ELEMENT recipeone (recipe_title,prep_time,cook_time,recipe_blurb,ingredients_list,ingredient*,quantity*,food_item*)>
    <!ELEMENT recipe_title (#PCDATA)>
    <!ELEMENT prep_time (#PCDATA)>
    <!ELEMENT cook_time (#PCDATA)>
    <!ELEMENT recipe_blurb (#PCDATA)>
    <!ELEMENT ingredients_list (#PCDATA)>
    <!ELEMENT ingredient (#PCDATA)>
    <!ELEMENT quantity (#PCDATA)>
    <!ELEMENT food_item (#PCDATA)>
    <!ELEMENT method (prep_ingredient,step_one,step_two,step_three,step_four,step_five,step_six)>
    <!ELEMENT step_one (#PCDATA)>
    <!ELEMENT step_two (#PCDATA)>
    <!ELEMENT step_three (#PCDATA)>
    <!ELEMENT step_four (#PCDATA)>
    <!ELEMENT step_five (#PCDATA)>
    <!ELEMENT step_six (#PCDATA)>
    ]>
    <cookbook>


    <frontcover>

    <title> Alice's Cookbook </title>
    <byline> "I love this book. I love everything about it: the recipes, the tone and, as importantly, Alice's warmth." </byline>
    <author> Alice Hart </author>

    </frontcover>

    <body>
    <recipeone>
    <recipe_title> Honey's Raspberry Turnover </recipe_title>
    <prep_time> Hands on Time: 15 mins </prep_time>
    <cook_time> 20 mins </cook_time>
    <recipe_blurb> Honey, my baker-extraordinaire, puff-pastry-making gradnmother, has been a dab hand with a turnover for as long as I can remember, churning out batches of apple, apricot or raspberry from a handsome blue Aga. Make sure you use all-butter puff pastry; it tastes better and has a much more wholesome ingredient
    list. </recipe_blurb>

    <ingredients_list>
    <ingredient> flour, to dust </ingredient>
    <ingredient> <quantity> 500g </quantity> of <food_item> all-butter puff pastry </food_item> </ingredient>
    <ingredient> <quantity> 500g </quantity> of <food_item> fresh raspberries </food_item>
    </ingredient>
    <ingredient> <quantity> 125g </quantity> of <food_item> vanilla sugar or caster sugar
    </food_item> </ingredient>
    <ingredient> <quantity> 1 </quantity> of <food_item> free-range egg yolk </food_item>
    mixed with <quantity> 1 tbsp </quantity> <food_item> milk </food_item> </ingredient>
    </ingredients_list>


    <method>
    <prep_ingredient> Pastry </prep_ingredient>
    <step_one> Flour surface. </step_one>
    <step_two> Roll out pastry to form a 1/2 thick rectangle. </step_two>
    <step_three> Straighten raggedy edges with a sharp knife. </step_three>
    <step_four> Cut pastry into eight even squares of 15x15cm. </step_four>

    <prep_ingredient> Raspberries </prep_ingredient>
    <step_one> Place a pile of respberries in each square, slightly off centre. </step_one>
    <step_two> Add a heaped teaspoon of sugar. </step_two>
    <step_three> Using a pastrry brucsh, paint a little water around the edge and bring one
    corner to meet its diaganol opposite. </step_three>
    <step_four> Press the edges together firmly to seal using the tines of a fork.
    </step_four>
    <step_five> Repeat to make eight pastries. </step_five>
    <step_six> Place pastries on a baking tray. </step_six>

    <prep_ingredient> oven time </prep_ingredient>
    <step_one> Preheat oven to 200 degrees/fan 190 degrees/gas mark 6. </step_one>
    <step_two> Brush pastry with egg wash (yolk and milk mixture). </step_two>
    <step_three> Sprinkle with a little more sugar. </step_three>
    <step_four> Cut a small vent in the top of each to let the steam out. </step_four>
    <step_five> Bake for 20 minutes, until exuberantly plump and golden. </step_five>
    <step_six> Cool on a wire rack and serve warm. </step_six>

    </method>
    </recipeone>


    </body>

    </cookbook>

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    You've declared that the ingredients_list element contains parsed character data but no ingredient elements. I think that what you want is:
    Code:
    <!ELEMENT ingredients_list (ingredient *)>
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Apr 2013
    Posts
    3
    That's definitely helped, thanks for such a quick response! So simple too!

    I've still got errors such as document type does not allow element "quantity" here

    This is the same for food _item as well.

    Any ideas?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13573 seconds
  • Memory Usage 2,862KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (3)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates