Results 1 to 5 of 5

Thread: Another XML Problem...

  1. #1

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Question Another XML Problem...

    Okay this time I'm having problems with XSL. I'm writing a little practice script so that I can get familiar with the concepts. I have an XML document that looks like this:

    HTML Code:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <?xml-stylesheet type="text/xsl" href="DictionaryDisp.xsl"?>
    <!DOCTYPE book [
    	<!ELEMENT book (term+, type_of_speech+, definition+, root+)>
    		<!ATTLIST book
    			title CDATA #REQUIRED
    			isbn CDATA #REQUIRED
    			publisher CDATA #REQUIRED
    			type (paperback | hardback) #REQUIRED
    		>
    	<!ELEMENT term (#PCDATA)>
    	<!ELEMENT type_of_speech (#PCDATA)>
    	<!ELEMENT definition (#PCDATA)>
    	<!ELEMENT root (#PCDATA)>
    ]>
    
    <book title="The American Heritage School Dictionary" isbn="0-395-24739-4" publisher="Houghton Mifflin" type="hardback">
    	<term>a, A</term>
    	<type_of_speech>noun, plural</type_of_speech>
    	<definition>The first letter of the English alphabet; The best of highest of a grade, as in school; In music, the sixth tone in the scale of C-major.</definition>
    	<root>N/A</root>
    </book>
    I'm still not sure if it's legal, or well-formedness, to have attributes in your root elements (if this is the case, please correct me) but my problem is that I want to display the attributes of the root element in my XSL file and I can't figure out how to get a hold of those peices of information in the XSL file. Any help would be appreciated.

    EDIT: Also, is it better to have, in tems of the XML document in question, an internal or external DTD?

  2. #2

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Re: Another XML Problem...

    bump
    Only those who try will become.

    Find me on identi.ca

    Twitter @gfmartin05

    Linux Wrap

  3. #3
    Fanatic Member kaihirst's Avatar
    Join Date
    Jul 2005
    Location
    The Resaurant At the End of The Universe
    Posts
    633

    Re: Another XML Problem...

    Hi,

    Anser to the last question, an external DTD.

    With the reltive question about good proactices in XML. XML is an undefined language with not specific set standards of tags, elements and a "formatted" way of writing or setting out your page, much to the opposite of HTML.

    There are no good and bad practices in this, onlly if you are interoperating and communicating with other businesses do you need to standardise your tag layout and practice, as it needs to be the same as the other user, so the answer to your question is whatever youre comfortable with.

    Duno about your elements question. ill get back to you.

    Kai
    As the information I give is useful in its nature, consider using the RATE POST feature located on the bottom left of this post please..

    A few things that make a good Developer a Great One.
    Methodical and a thorough approach to research and design inevitably leads to success.
    Forward thinking is the key to Flow of control.
    Never test in the design environment, always test in real time, you get the REAL results.
    CBSE & OOSE are the same animal, they just require different techniques, and thinking.
    SEO is a globe of objectives, SE rankings is an end to a means for these objectives, not part of them.
    The key to good design is explicit attention to both detail and response.
    Think Freely out of the "Box" you're in..... You will soar to better heights.

    Kai Hirst - MSCE, MCDBA, MCSD, MCP, MCAP, MSCT


  4. #4

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Re: Another XML Problem...

    Thx again
    Only those who try will become.

    Find me on identi.ca

    Twitter @gfmartin05

    Linux Wrap

  5. #5
    New Member
    Join Date
    Nov 2005
    Location
    UK
    Posts
    15

    Re: Another XML Problem...

    Hi,
    It is possible to display the attributes of the root element. In the XSL file it will look something like this:

    <xsl:template match="/">
    <html>
    <body>
    <xsl:value-of select="root element/@attribute" />
    </body>
    </html>
    </xsl:template>


    ie. you navigate to the location of the attribute using Xpath commands

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