|
MarSCoZa wrote:
<para>The earth rotates.
Technically that kind of XML is not really valid.
e.g.
<para>
The
<link url="earth.htm">earth</link>
rotates.
</para>
The The and Rotates PCDATA sections are "floating".
The reason being that an element can either only contain PCDATA or child-elements. It cannot contain both. Think about creating a DTD which defines that... You cannot really. The DTD element definition cannot contain PCDATA and an elements name.
However XML is quite forgiving in this case (which is strange considering it's normally very unforgiving nature) and you can use the following XSL to transform it.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head>
</head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="link">
<a>
<xsl:attribute name="href">
<xsl:value-of select="@url" />
</xsl:attribute>
<xsl:value-of select="."/>
</a>
</xsl:template>
</xsl:stylesheet>
The key is templates . I used to hate them and thought they were these daft, never used bits of XSL. Until I figured out how they worked and went "oooohh yes!"
Enjoy!
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
|
|
|
|
|
Paul Watson wrote:
The key is templates. I used to hate them and thought they were these daft, never used bits of XSL. Until I figured out how they worked and went "oooohh yes!"
I've never used XSLT for XML->HTML, but with XML->XML, templates are the god you bow down to and pray. It boggles my mind the thought of NOT using template matching in XSLT.
|
|
|
|
|
I have an XML document which I need to turn into a new format, where a small portion of it gets put in <static> tags, the rest does not. There is a LOT of XML on this page.
I've got the first half done, easy enough. Now I want to write a filter which, instead of saying 'include these tags and children', I want to say 'EXCLUDE these tages and children, include everything else'. How do I do that ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - <b>Martin Marvinski, 6/3/2002</b>
|
|
|
|
|
Which language and parser are you using to process the XML?
|
|
|
|
|
I'm using XSL, I got it working this afternoon - thanks.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Christian Graus wrote:
I got it working this afternoon - thanks.
How did you do it? I might run into that problem one day and need to know how, thanks
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge
Sonork ID: 100.9903 Stormfront
|
|
|
|
|
My first pass would have been to use the count(tag) function and only processed if it returned 0.
Good ideas are not adopted automatically.
They must be driven into practice with courageous patients. -Admiral Rickover. ...
|
|
|
|
|
The trick is that a more generic filter will only include items that were not included in a more specific filter. I wrote specific filters for the tages I needed, then a generic filter, and it excluded all the items that the specific tags caught.
If that's not clear LMK, I can post the code from work tomorrow.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Anybody know how to use Voice XML ?
What do I need, how do I set it up ?
Any info would be useful.
Users.
Can't live with 'em, can't kill em!
|
|
|
|
|
VoiceXML is just a standard. Go here and grab the specs. Then, grab the parser ang language of your choice and start writing a processor.
Of course, there might be ones out there. I'm going by the work we did about a year ago for a copy that used VoiceXML. We had to write our own processor.
J
|
|
|
|
|
I need to validate an XML document against a schema, but I'm not having much luck finding a complete example in MSDN.
This is the pseudo code of what I want to do:
<br />
XMLValidater xVal = new XMLValidater("my dtd, etc...");<br />
XMLDocument xDoc = new XMLDocument("my XML doc");<br />
if (xVal.Validate(xDoc))<br />
Help would be cool.
Cheers,
Simon
X-5 452 rules.
|
|
|
|
|
I haven't looked at it but isn't XmlValidatingReader what you need?
|
|
|
|
|
Something very basic must be alluding me because this seems like an obvious thing that people would want to do in XSL, but for the life of me I cannot figure out how to do it.
I have one XML file with some content in it. I then have a master XSL file which transforms the XML into nice HTML for the browser.
However that XSL file needs to be a combination of other XSL files. i.e. It is a normal ASP with include statements idea.
So I need to know how to import sections of XSL into another XSL document.
dankie shan.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge
Sonork ID: 100.9903 Stormfront
|
|
|
|
|
Have you tried using <xsl:import> or <xsl:include>? Works for me.
|
|
|
|
|
MarSCoZa wrote:
Have you tried using <xsl:import> or <xsl:include>? Works for me.
Yup, I, or rather my co-worker, used that but could not figure out how to actually apply the included templates at the spots she wanted. I found the xsl:call-template element and that worked perfectly.
Thanks for the input
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge
Sonork ID: 100.9903 Stormfront
|
|
|
|
|
I figured it out. It was actually a problem a co-worker had and I had not sat down and tried anything until last night, it came relatively easy once I got stuck in.
The way to do it is using the <xsl:include href="file to include" /> and then the <xsl:call-template name="template name to call" /> elements.
If anyone wants an actual code example then please just ask.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge
Sonork ID: 100.9903 Stormfront
|
|
|
|
|
Quick backstory: I have an app that has a customizable menu, controlled by an XML file. The format looks like:
<menuitem id="foo" url="blah" icon="somefile.ico" /> The weirdness is, two of my partners are seeing a bug where if the same icon value is in multiple <menuitem> tags, those (and only those) attributes can't be read. MSXML returns an empty string instead. I cannot reproduce this myself. Any ideas on WTF is going on here?
--Mike--
Rollin' in my 5.0
With the rag-top down so my hair can blow.
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Michael Dunn wrote:
Any ideas on WTF is going on here?
Simple: they are insane.
Crivo
Automated Credit Assessment
|
|
|
|
|
I have a very similar structure and have never had any problems like you describe. As far as the XML parsing goes you are saying if the text field for a specific attribute is repeated you can only read the first occurance.
To me this sounds more like either the XML is not quite formed right but I would think you would notice not steping through the elements correctly, so doubtful.
Or it is not in the parsing but the calling code.
Sorry for asking but is it really the same code as on your machine?
Try reading it in with some of the samples apps here and see if they behave the same.
Good ideas are not adopted automatically.
They must be driven into practice with courageous patients. -Admiral Rickover. ...
|
|
|
|
|
|
Is this the planned but so far kept secret "Ask Paul Watson" forum?
Nish
p.s. And when will we have the "Talk with Nish about your mental illusions" forum?
Bow wow wow,
Yippee yo yippee yay,
My miniputt high,
Is now 30 yay.
|
|
|
|
|
|
Wow!!!!
Yeah it worked for me too...
Nish
Bow wow wow,
Yippee yo yippee yay,
My miniputt high,
Is now 30 yay.
|
|
|
|
|
Roger Wright wrote:
I just typed in http://www.codeproject.com/askPaulWatson.asp and ended up here!
Roger!!!
How did you guess???
Nish
Bow wow wow,
Yippee yo yippee yay,
My miniputt high,
Is now 30 yay.
|
|
|
|
|
You mean you didn't set up a redirector or anything? Damn, I may be psychic! Or is that "psychotic?"
|
|
|
|