Jump to content

steve_marjoribanks

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by steve_marjoribanks

  1. Homework question is it?! You really should be able to do that just after reading the tutorial.
  2. Well you're schema has a target namespace and your XML document is using a noNamespaceSchemaLocation attribute. The clue is in the name of the attribute. Try reading up on XML namespaces, it can be quite confusing!
  3. Your answer is no!XML Schemas are purely for validation purposes and cannot perform any sort of interactions with databases, applications or anything! You have to use a separate programming language which can be used along with XML to achieve this.
  4. This cannot be done simply by using the XML Schema langiage. Instead you have to use something like Schematron (do a google search) and use it within your schema
  5. Yes, using an XML editor such as XMLSpy or Visual Studio you can create an XML file based upon the constraints of a specified schema.
  6. I think you should strongly consider re-structuring your XML so it looks like this:<artist> <firstName>Nusrat</firstName> <lastName>Ali</lastName></artist>Using mixed content elements is not recommended for data storage of this kind.
  7. I have found that Firefox doesn't really like XSL stylesheets! Whenever I try to view an XML document with an associated XSL stylesheet in Firefox it *always* comes up with that error. This maybe something I am doing wrong, or I need to download a patch or something (in which case I would very much appreciate some input!).In answer to your question, just try it in Internet Explorer, I think it will probably work!
  8. I guess you're wanting the output to be in the form of a page in a web browser? If so, your stylesheet will be in html anyhow so can't you just put a <br/> in where you want the new line?
  9. You only waited 3 hours for an answer!!! People aren't likely to jump to help you in future if you carry on with an attitude like that are they?!
  10. You can but you would use them in this case as: <cd test2="test1:test">ie. specifying the namespace in the attribute value rather than in the name. If this is causing problems you could always just get rid of the attribute and use an element instead eg.<cd> <test1:test2>test</test1:test2></cd>
  11. I'm not quite sure where you got the example from because I can't see any code with a test1:test2 attribute? As far as I'm aware test1:test2 is an invalid attribute name, they may only contain letters, numbers, dots and hyphens.To answer your second question, you use a namespace declaration attribute in the root element of your document. Something like xmlns:SOAP="insert a URL for the namespace here". Then you prefix each element in that namespace with SOAP:See http://www.w3schools.com/xml/xml_namespaces.asp for more.
  12. Not really sure where I should post this but here will do!I am currently doing quite a bit of work on a data exchange format in XML. As part of this I need to use XLink and XPointer attributes quite frequently as one of the requirements is for the data in the documents to be 'linked' to its source. Currently, as far as I'm aware there is very little (if any) software/browser support for XPointer.My question is that would it be possible (and if so how difficult) for me to write a small application which could use the XPointer stuff. ie. you could load an XML document into it and through some sort of very simple interface it could say retrieve the source of the required data when asked to and display it in another frame for example?What are everyone's views on this? How difficult would it be to write, and if not too difficult what language would you recommend writing it in, I'm guessing either Java or VB?Thanks!!!
  13. Or just this<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><xsl:value-of select="data/field/value/@date" /><xsl:value-of select="data/field/value/@audience" /><xsl:value-of select="data/field/value/@message" /></xsl:template></xsl:stylesheet>
  14. To get a value of an attribute you use <xsl:value-of select="@attributename" />edit: or do you mean you want to use the attribute values in the xsl code so that all 3 of the value tags are displayed correctly and not just the first one 3 times? If so you can do this using XPath, specifically by identifying the position of the element you wish to extract the data from within its parent node. See http://www.w3schools.com/xpath/xpath_syntax.asp
  15. steve_marjoribanks

    XML,XSL

    As said above, you need to make sure all your closing tags are the same as your opening tags, watch for capital letters!Again, closing tags are of the format </name> not <name/>. The reason i put it like <Recipient no="1" custno="12345" /> is that you are using an empty element and so you can use the shorthand of the /> at the end of the element. It is empty because you don't have any data stored in there, only attribute values. As mentioned above, it is generally a better idea to store data in element form as it is more versatile then.If the data has to be stored as attributes then you have to search for the data in the attributes. At the moment you are telling it to look for an element called custno, not an attribute.You need to change it to:<xsl:for-each select="Recipients/Recipient"><xsl:value-of select="@custno"/></xsl:for-each>the @ tells it to look for an attribute name and not an element name.
  16. steve_marjoribanks

    XML,XSL

    The problem is that you have used empty Recipient tags and no closed them properly. It should be: <Recipient no="1" custno="12345"/> <Recipient no="2" custno="23456"/> <Recipient no="3" custno="34567"/>
  17. Could you maybe post the code you are using?
  18. I have written an XML file in Visual Studio.Net and then it has created a schema for me (hence there a few unecessary namespace references in there). The problem is that when i try to validate the xml file against the schema in Visual Studio it says it cannot locate the schema document, even though all the paths specified are correct. It could be a problem with Visual Studio because there are a few other features which are a bit iffy. I have tried looking for online tools that will check a document against a schema but only found http://apps.gotdotnet.com/xmltools/xsdvalidator/ which is offline at the moment!Is there any other way for me to check it, or can any of you see any errors i have made in the code? I'm not too bothered if there are a few small errors in the schema with regards to the syntax of the xml file at the moment but i just want to know why Visual Studio cannot locate the schema file to check againstMany thanksPractice.xml <?xml version="1.0" encoding="UTF-8"?><GeotechnicalProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.dur.ac.uk/s.j.marjoribanks" xsi:schemaLocation="practice.xsd"> <projectDetails> <title>Practice XML file</title> <date>2005-11-09</date> <author>Stephen Marjoribanks</author> <revision /> <notes>Sample borehole data taken from RF Craig Soil Mechanics 6th Edition, Table 10.1 pg419</notes> </projectDetails> <project> <SiteInvestigation> <holes> <Borehole> <holeDetails> <Location>Barnhill</Location> <Method>Shell & Auger to 14.4m, Rotary core drilling to 17.8m</Method> <Diameter>150</Diameter> </holeDetails> <groundProfile> <layer> <Top>0.00</Top> <Bottom>0.70</Bottom> <Name>Topsoil</Name> <Description>Topsoil</Description> </layer> <layer> <Top>0.70</Top> <Bottom>2.60</Bottom> <Name>Sand</Name> <Description>Loose, lightly brown SAND</Description> <Constituent> <description>Sand</description> <type>Soil</type> <consistency>Loose</consistency> <mainColour>Light brown</mainColour> <amount>Main</amount> </Constituent> </layer> <layer> <Top>2.60</Top> <Bottom>4.40</Bottom> <Name>Gravelly Sand</Name> <Description>Medium dense, brown gravelly SAND</Description> <Constituent> <description>Sand</description> <type>Soil</type> <consistency>Medium dense</consistency> <mainColour>Brown</mainColour> <amount>Main</amount> </Constituent> </layer> <layer> <Top>4.40</Top> <Bottom>12.20</Bottom> <Name>Clay</Name> <Description>Firm to stiff, yellowish brown, closely fissured CLAY of high plasticity</Description> <Constituent> <description>Clay</description> <type>Soil</type> <consistency>Firm to Stiff</consistency> <plasticity>High</plasticity> <mainColour>Brown</mainColour> <secondaryColour>Yellow</secondaryColour> <amount>Main</amount> <notes>Closely fissured</notes> </Constituent> </layer> <layer> <Top>12.20</Top> <Bottom>14.40</Bottom> <Name>Sand</Name> <Description>Very dense, red, silty SAND with decomposed SANDSTONE</Description> <Constituent> <description>Sand</description> <type>Soil</type> <consistency>Very dense</consistency> <mainColour>Red</mainColour> <amount>Main</amount> <notes>Silty</notes> </Constituent> <Constituent> <description>Sandstone</description> <type>Rock</type> <consistency>Decomposed</consistency> <mainColour /> <amount>Secondary</amount> </Constituent> </layer> <layer> <Top>14.40</Top> <Bottom>17.80</Bottom> <Name>Sandstone</Name> <Description>Red, medium-grained, granular, fresh SANDSTONE, moderately weak, thickly bedded</Description> <Constituent> <description>Sandstone</description> <type>Rock</type> <consistency>Granular</consistency> <mainColour>Red</mainColour> <grainSize>Medium</grainSize> <strength>Moderately weak</strength> <bedding>Thickly bedded</bedding> <notes>Fresh</notes> </Constituent> </layer> </groundProfile> </Borehole> </holes> </SiteInvestigation> </project></GeotechnicalProject> Practice.xsd <?xml version="1.0" encoding="UTF-8" ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.dur.ac.uk/s.j.marjoribanks" <!--xmlns="http://www.dur.ac.uk/s.j.marjoribanks"--> <xs:element name="GeotechnicalProject"> <xs:complexType> <xs:sequence> <xs:element name="projectDetails"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string" minOccurs="1" /> <xs:element name="date" type="xs:date" minOccurs="0" /> <xs:element name="author" type="xs:string" minOccurs="0" /> <xs:element name="revision" type="xs:string" minOccurs="0" /> <xs:element name="notes" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="project"> <xs:complexType> <xs:sequence> <xs:element name="SiteInvestigation" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="holes" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="Borehole" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="holeDetails" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="Location" type="xs:string" minOccurs="0" maxOccurs="1" /> <xs:element name="Method" type="xs:string" minOccurs="0" maxOccurs="1" /> <xs:element name="Diameter" type="xs:string" minOccurs="0" maxOccurs="1" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="groundProfile" minOccurs="0" maxOccurs="1"> <xs:complexType> <xs:sequence> <xs:element name="layer" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="Top" type="xs:float" fixed="1" /> <xs:element name="Bottom" type="xs:float" fixed="1" /> <xs:element name="Name" type="xs:string" minOccurs="0" /> <xs:element name="Description" type="xs:string" minOccurs="0" /> <xs:element name="Constituent" minOccurs="1" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="description" type="xs:string" minOccurs="0" /> <xs:element name="type" type="xs:string" fixed="1" /> <xs:element name="consistency" type="xs:string" minOccurs="0" /> <xs:element name="mainColour" type="xs:string" minOccurs="0" /> <xs:element name="amount" type="xs:string" minOccurs="0" /> <xs:element name="plasticity" type="xs:string" minOccurs="0" /> <xs:element name="secondaryColour" type="xs:string" minOccurs="0" /> <xs:element name="notes" type="xs:string" minOccurs="0" /> <xs:element name="grainSize" type="xs:string" minOccurs="0" /> <xs:element name="strength" type="xs:string" minOccurs="0" /> <xs:element name="bedding" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element></xs:schema>
  19. Ahh thanks! I thought it might be a namespace issue. I haven't really got my head round the whole namespace thing yet!
  20. Hi!I'm not really sure if this is an HTML problem or an XML problem so i thought i would just post a link here! Any help would be greatly appreciated clicky clicky
  21. Hi everyone, i'm hoping you can help me with a small code problem. I'm new to both HTML and XML and i've written just a very small .xml file to practice. I've also created an .xsl stylesheet which should display the data in a simple table in HTML. However when i open the file address.xml in internet explorer, the data has been sucessfully extracted from the XML file but it is just displayed as a long string of text not in the table as the stylesheet says. Basically, the HTML part isnt working for some reason. Hope you can help! Thanks :)Address.xml <?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="Address.xsl" ?><AddressBook xmlns="http://tempuri.org/Address.xsd" schemaLocation="Address.xsd"> <Person> <FirstName>Stephen</FirstName> <Surname>Marjoribanks</Surname> <University>Durham</University> <College>Trevelyan</College> </Person> <Person> <FirstName>Joe</FirstName> <Surname>Bloggs</Surname> <University>Leeds</University> <College /> </Person></AddressBook> Address.xsl <?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/AddressBook"> <HTML> <HEAD> <TITLE>Address Book</TITLE> </HEAD> <BODY> <H1>Address Book</H1><br/> <HR/> <TABLE BORDER="1"> <TD>First Name</TD> <TD>Surname</TD> <TD>University</TD> <TD>College</TD> <xsl:apply-templates/> </TABLE> </BODY> </HTML> </xsl:template> <xsl:template match="Person"> <TR> <TD> <xsl:value-of select="FirstName" /> </TD> <TD> <xsl:value-of select="Surname" /> </TD> <TD> <xsl:value-of select="University" /> </TD> <TD> <xsl:value-of select="College" /> </TD> </TR> </xsl:template> </xsl:stylesheet>
×
×
  • Create New...