1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How do I create XML in PHP using a XSD Schema

Discussion in 'PHP' started by kb4, Jul 25, 2008.

  1. #1
    Hello,

    I have a premade XML schema from a third-party but wish to know is it possible to use this as a way of creating an XML document that conforms to this schema using PHP ?

    I'm using a schema from Garmin :

    http://www.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd

    ..and my website creates a series of points from a google map which will form the data of a course, eventually to be put into a .TCX file (Garmin's own XML document). The schema provides the framework for the .TCX file but how can I use the schema to generate the file ? As far as I have read, schemas are only good for validating XML files. So how does one use a schema to create an XML file (using PHP) ? Or is this not the purpose of schema ?

    Many thanks for anybody's reply
     
    kb4, Jul 25, 2008 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    Short answer, it doesn't. The schema is the blueprint. It tells you what is allowed, what's required and where it goes. It does nothing to put it there, that's the coder's job. The schema helps though since lots of questions are answered already.
     
    shallowink, Jul 25, 2008 IP
  3. kb4

    kb4 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply shallowink.. I suspected as much !

    The thing is.. a schema, particularly the one I have to work with is not really in a human readable form, it would be much better presented graphically as a tree. Are there any freeware programs that will present schemas as such ?
     
    kb4, Jul 26, 2008 IP
  4. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #4
    What I did was I took the php xml parser and made it parse the XSD. Essentially looking for minOccurs so I knew what was required then printed out the annotations to give me a semi legible copy to work from. Maybe that's not what you want, maybe cooktop or one of the other xml editors would help you more.
     
    shallowink, Jul 26, 2008 IP
  5. kb4

    kb4 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Cheers shallowink. Your advice greatly appreciated ! :)
     
    kb4, Jul 26, 2008 IP