Hi, I think the only way to do this is to pass in the date and pick it up in your stylesheet as a global parameter using xsl:param
. The way you pass parameters in to the stylesheet is processor specific, so for instance in .Net there is a XsltArgumentList
class. Cheers Phil Hobgen barbari.co.uk Southampton, UK
Phil Hobgen
Posts
-
XSL GetDate function ? -
Process XML from inside XMLHi, Having a bit more of a think.... If you are working to a schema, and the format of the xml currently in
Value
is not clearly definable then, if you can change the schema, you could just use anxs:any
element (withmaxOccurs="unbounded"
) to define the nested xml but place it within theVariable
element. If there is no schema then you could just move the xml as above anyway, with no worries about schema changes. So there is no need for a CDATA section really. Of course in either case you may be exchanging this data with someone else, who you may or may not be able to get agreement with :) If you can't move the 'encoded' xml, and presuming it is all properly escaped, I think maybe the place to start is to select theValue
attribute into avariable
. This would contain a tree fragment that you can perform all the usual xslt stuff on. For instance you could set up atemplate
with amatch
ofALL_RESULTS
, you could call the template withapply-templates
with aselect
on the variable you have created. If that doesn't work then perhaps you could pass the variable into aparam
of thetemplate
and process it that way. I dont think it matters that the source for the variable is text containing < as opposed to < etc, the xslt processor can't tell the diference, I think :-D Sorry I dont have time to test out the theory - I would be interested to hear how you get this to work.. Cheers Phil Hobgen barbari.co.uk Southampton, UK -
Process XML from inside XMLHi, dnh wrote: Didn't he write "the document contains xml encoded inside the xml". I'd guess it is escaped. But my English is self-thought ( in computer terminology), so word "encode" has only one meaning to me ... You're probably right. :doh: I must admit to having been somewhat surprised to see xml like that. dnh wrote: other ideas? Not really. If the xml structure can be changed then a CDATA section sounds like just the right approach. Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
Process XML from inside XMLHi, As it appears here, your xml is not valid. The "<" character cannot appear within an atribute value, unless you escape it as < Also you have " charaters embedded within an attribute value that uses the same " character to enclose the attribute value, you could escape the inner quotes as " You need to fix the xml before you can look at the xslt. Are you able to change the xml structure? If the attribute must contain xml, then you will have to escape the appropriate characters, after that you will be able to use the value-of element to retrieve the escaped xml. At that point, I guess you would need to 'un-escape' it. Sounds complicated... Good Luck, Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
Display Image from XML sourceHi, If you are saying that you have some xml that is a bit like either :
<sometag>url('http://www.somewebsite/image/myimage.jpg')</sometag>
or :<sometag someattr="url('http://www.somewebsite/image/myimage.jpg')" />
If you are using XSLT then you could trim the outer parts of the string using a combination of string functions from:string-length()
,substring()
,substring-before()
, andsubstring-after()
or maybe just two consecutive calls totranslate()
would do it. You could just output the value of whats left over into thesrc
attribute This probably isn't very efficient (string functions), if you have to do it a lot, but if thats whats in the xml you might have to resort to something like this. Cheers Phil Hobgen barbari.co.uk Southampton, UK -
Page Header/Footer in HTMLHi, This is really something that you probably need to do using CSS, with an alternate stylesheet - CSS2 has some support for print layout and there are moves to improve on this, but I'm not sure what the current browsers support. You could do it with XSLT (if your source is XML), and generate different pages for browsing/printing, but this would be v. complex I suspect. You could even use XSLF for generating a PDF for strict layour printing, I would think this can get even more complex. Unless you're really in to XSL .... I think your best bet is to have a search for articles on css printing. Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
How do I add a DOCTYPE declaration in XML using MSXML in Visual C++?Hi, I think what you want is the IXMLDOMDocumentType interface which inherits from an IXMLDOMNode so you should be able to deal with it like any other node. Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
Print Values in XSLTHi, This doesn't seem like a very elegant solution. I'm sure there must be a better way, but I couldn't get there :( Hope this helps.
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="unique-years" select="/ROOT/CAR/SALES[not(@Year=preceding::*/@Year)]/@Year" />
<xsl:variable name="unique-carnames" select="/ROOT/CAR[not(@Name=preceding::*/Name)]/@Name" />
<html>
<body>
<table>
<tr>
<td> </td>
<xsl:for-each select="$unique-carnames">
<xsl:sort select="." />
<td><xsl:value-of select="." /></td>
</xsl:for-each>
</tr>
<xsl:for-each select="$unique-years">
<xsl:sort select="." />
<tr>
<xsl:variable name="this-year" select="."/>
<td><xsl:value-of select="$this-year" /></td>
<xsl:for-each select="$unique-carnames">
<xsl:sort select="." />
<xsl:variable name="this-car" select="."/>
<td><xsl:value-of select="/ROOT/CAR[@Name=$this-car]/SALES[@Year=$this-year]" /></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
A beginner questionHi, XML can be used anywhere where you can use text. You can pass it around in files, or over the web. SOAP is a protocol that uses XML for sending/receiving to call methods, this doesn't sound like what you want. To do the binary encoding take a look at base64 encoding. Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
XSLT QuestionHi, This should get you started - it's not in a table, but you should get there from here
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html> <body> <h1>Cricket</h1> <xsl:apply-templates select="CRICKET/TEAM"/> </body> </html> </xsl:template> <xsl:template match="TEAM"> <h2><xsl:value-of select="@Name" /></h2> <xsl:apply-templates select="PLAYER"/> </xsl:template> <xsl:template match="PLAYER"> <h3><xsl:value-of select="." /></h3> </xsl:template> </xsl:stylesheet>
Cheers Phil Hobgen barbari.co.uk Southampton, UK -
XMIHi, A starting point would be the OMG web site generally, and maybe this page http://www.omg.org/technology/xml/index.htm[^] in particular. From what I know, it's just an XML language for describing UML models so they can be exchanged between different vendors modelling tools. It can't take the place of UML as it is just a standard language for describing UML models. As for its' future - personally I can't see much call for it in the real world, except maybe for large open source projects where a number of different UML editors might be used by different contributors. From my experience organisations tend to standardise on the use of a single modelling tool, so unless they want to exchange models externally they would have no call for XMI. I have no real idea, but perhaps it is possible be that certain vendors would like to use XMI to store the models generated by their modelling tools, however xml would seem to be an extremely inefficient way to store this data. A bit like storing very large spreadsheets as XML, only worse! It would be interesting to hear what started your interest in XMI? Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
A beginner questionHi, The best place to start is with some questions : 1) What's your development environment? 2) Is there an existing XML Schema that you need to comply with? If you are exchanging the data with an external system, a schema is useful as a definition of the exchanged data format. Alternatively you may just be able to agree a simple xml structure. 3) Do you need to enclose the binary data in the xml, or could you use a url within the xml to indicate where the binary data can be retrieved from? If you need to enclose the binary data then you will need to encode it, as xml does not allow binary data. Note that this encoding will expand the size of the binary data, and hence the size of your xml. 4) When you transmit via TCP/IP do you mean HTTP, a web service, or some other standard protocol or just from port to port using some 'informal' protocol? A good link to bookmark is http://www.zvon.org[^] Good Luck! Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
Processing InstructionHi, I'm not sure how you are transferring the xml to the browser. To work out if the problem is with the
XmlDocument
or with the transfer of the xml you could try a call toSave("SomeDirOnTheServer\\SomeFileName.xml");
Phil Hobgen barbari.co.uk Southampton, UK -
Processing InstructionHi, I've never seen the PI anywhere but before the root element. So that should be correct. Are you sure that "wsinfo.xsl" is located relative to the url that returns the xml? When you say the PI is not displayed in IE, do you mean in the browser or in the "View Source" notepad? The xml shouldn't be seen in the browser, you should see the result of the transformed xml. Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
Problem while Working with XmlValidatingReader!!!!!Hi, Sorry, I haven't started working with it yet. I'd merely made myself a note that XmlValidatingReader will have to be replaced when I move some existing code to v2.0 Good Luck Phil Hobgen barbari.co.uk Southampton, UK
-
Problem while Working with XmlValidatingReader!!!!!Hi, The XmlValidatingReader class is obsolete in v2.0. You can read about validating xml in v2.0 here: http://msdn2.microsoft.com/library/hdf992b8.aspx[^] Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
XmlTextWriter 101Hi, There isn't an
XmlTextWriter
constructor that takes aFileInfo
as a parameter. There's a choice of three constructors, it looks like you probably want to use this one:public XmlTextWriter(string filename, Encoding encoding);
Cheers Phil Hobgen barbari.co.uk Southampton, UK -
Problem while Working with XmlValidatingReader!!!!!Hi, The
XmlValidatingReader
class is obsolete in v2.0. You can read about validating xml in v2.0 here: http://msdn2.microsoft.com/library/hdf992b8.aspx[^] Cheers Phil Hobgen barbari.co.uk Southampton, UK -
about computer in a domainHi, Put a textbox (multiline) and a button on a form, try this button click handler, as a start:
private void button1_Click(object sender, System.EventArgs e)
{
DirectoryEntry de = new DirectoryEntry("LDAP://myserver.mydomain");
DirectorySearcher ds = new DirectorySearcher(de);
ds.Filter = ("(objectClass=computer)");
foreach(SearchResult res in ds.FindAll())
{
textBox1.AppendText(res.GetDirectoryEntry().Name + System.Environment.NewLine);
}
}Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
Refresh Page ProblemHi, You can do this with the html
<object>
elements. Set thedata
attribute to the url of an embeded page, set thetype
attribute to "text/html", and you'll need to set thewidth
andheight
attributes as well. Then the embeded page(s) can use meta refresh without affecting the whole page. Cheers Phil Hobgen barbari.co.uk Southampton, UK