|
I'm not sure about C++ but in managed code it would be fairly easy to do using classes provided in System.Net namespace.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Does anyone know where I can find a xslt file to transform xml into html or how to open a new browser window from asp.net to display the xml. I have a string that contains the xml that is generated from an object. I want to display the xml to the user in the browser. The format can change so writing a custom xsl is time consuming. I just want to display the xml as would be done if you open up an xml file in the web browser. However, must of the xsl files that exist on a windows pc for doing this are specifically designed to be run by the browser and don't use the standard schema that is required by XslTransform. I want the data to be displayed in a nicely color and formated XML format. If anyone has any help for me on this it would be greatly appreciated.
|
|
|
|
|
Adam Gritt wrote:
Does anyone know where I can find a xslt file to transform xml into html
In every book on xslt, and probably every website. It's a very obvious and typical use. There's no such thing as a generic transform though, it needs to be written to match the schema of your xml, and the format of the desired output.
If you just want to show the XML, you just need to htmlencode it. What language are you using ? C# certainly provides a method to do this, if you're using asp.net.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
hi folks...
I apologize for reposting but some code was trimmed in the previous post...
<xsl:choose>
<xsl:when test="./test[1]/@result != 'failed'">
<xsl:otherwise>
<xsl:value-of select="@name">
I need to change the color of tr to red when @result attribute contains "failed". When i executed above snippet i got the following error.
"End tag 'xsl:when' doesn't match the start tag 'tr'"??
Any workarounds ??
Thanks in advance...
Regards,
Hatim Ali.
|
|
|
|
|
hi
you need to close the first element using
|
|
|
|
|
hi folks...
<br />
<xsl:choose><br />
<xsl:when test="./test[1]/@result != 'failed'"><br />
<tr style="color:green; font-family:verdana; font-size:12 px;"><br />
</xsl:when><br />
<xsl:otherwise><br />
<tr style="color:red; font-family:verdana; font-size:12 px;"><br />
</xsl:otherwise><br />
</xsl:choose><br />
<td width="60%" style="border:gray 1px solid;"><br />
<xsl:value-of select="@name"/><br />
</td><br />
</tr><br />
I need to change the color of tr to red when @result attribute contains "failed". When i executed above snippet i got the following error.
"End tag 'xsl:when' doesn't match the start tag 'tr'"??
Any workarounds ??
Thanks in advance...
Regards,
Hatim Ali.
|
|
|
|
|
Well, you've not posted your xslt, but the problem is exactly as the message says, and the work around is to make your html valid xml. You have two tr starting elements, and only one is being closed.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Try something like this giving condition in this way dont know what is there in ur xsl, but this might work if there is only 1 condition
<xsl:if test="age > 40">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:if>
or try with choose
<td><xsl:value-of select="title"/></td>
<xsl:choose>
<xsl:when test="age > 10">
<td bgcolor="#ff00ff">
<xsl:value-of select="artist"/></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="artist"/></td>
</xsl:otherwise>
</xsl:choose>
here age artist title etc are tags of XML
try this out!
Be Humble in Victory and Strong in Defeat. -Het
|
|
|
|
|
Need some problems with character entities again.I am using msxml3 DOM API
Basicly I have to perform 3 steps:
1.Read some text, create and add it to a node
<nodetext> This is a test </nodetext>
2. Add a character entitie to that node
<nodetext> This is a test &en_test; </nodetext>
3. Add some text to that node later in my code.
<nodetext> This is a test &en_test; New Text </nodetext>
I am having difficulties with the 3rd step. I am using the createEntityReference method to add the entities but how do I add more text to the node and preserve the format of the entity. I need this to work badly.Someone please give me a hint ?!
|
|
|
|
|
I am using msxml DOM API to create XML documents and I need to insert character entities like
& #013; and etc If it I tried everything but it just wont work. Can someone help me on this subject please ?
|
|
|
|
|
I got it a simple \x0D did the job, RTFM as people say ;]
|
|
|
|
|
I tring to pass a XmlElement(DataSet) to a xml web service
How can I write in asp.net C# to write this XmlElement
<School>
<Student>
<NameFirst>Bill</Name>
<NameSecond>Evans</NameSecond>
</Student>
<Student>
<NameFirst>Tom</Name>
<NameSecond>Evans</NameSecond>
</Student>
<School>
|
|
|
|
|
I'd like to pass a parameter into an XSLT to search for a specific element within an XML document. My document has this form:
<library>
<folder id="1">
<file />
<file />
</folder>
<folder id="2">
<file />
<folder id="3" />
<folder id="4">
<file />
<file />
</folder>
</folder>
</library>
I want to be able to pass in a parameter into my XSLT and search for a particular folder - let's say id="4".
This is how I've been approaching it:
<xsl:stylesheet ...>
<xsl:param name="folderID" />
<xsl:template match="/library//folder[@id=$folderID]">
<!-- more code here -->
</xsl:template>
</xsl:stylesheet>
But I get this error: System.Xml.Xsl.XsltException: '/library//folder[@id=$folderID]' is an invalid XPath expression. ---> System.Xml.XPath.XPathException: /library//folder[@id=$folderID] is an invalid key pattern. It either has a variable reference or key function.
What might be a better or more correct way to approach this?
Michael Hodnick
|
|
|
|
|
Hi Michael. At first glance, I think the syntax
<xsl:template match="/library//folder[@id=$folderID]"> is wrong. You have two slashes between library and folder - did you want instead something like this?
<xsl:template match="//folder[@id=$folderID]"> to match a folder node regardless of where it is in the heirarchy?
|
|
|
|
|
I've also tried what you are suggesting, but still receive the following error: '//folder[@id=$folderID]' is an invalid XPath expression. ---> System.Xml.XPath.XPathException: //folder[@id=$folderID] is an invalid key pattern. It either has a variable reference or key function.
Michael Hodnick
www.kindohm.com
blogs.kindohm.com
|
|
|
|
|
I've just tried your approach in xsltproc (part of libxslt) and it works fine. I presume you are passing a value for folderID into the transform engine???
I used the command 'xsltproc --param folderID 4 a.xsl a.xml' to perform the transform (the xsl and xml names are obvious )
This was the XSL I used (based on yours - the template selector is the same as yours)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsl">
<xsl:output method="xml" encoding="ISO8859-1" indent="yes" omit-xml-declaration="no"/>
<xsl:param name="folderID"/>
<xsl:template match="/library//folder[@id=$folderID]">
<Wib>
<xsl:value-of select="count(./file)"/>
</Wib>
</xsl:template>
</xsl:stylesheet>
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
My previous reply was wrong - you can't use a variable reference in a template selector - see this
You'll have to use something like the following instead (i.e. put the predicate on a higher-level select expression and keep the template matching rule wide):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsl">
<xsl:output method="xml" encoding="ISO8859-1" indent="yes" omit-xml-declaration="no"/>
<xsl:param name="folderID"/>
<xsl:template match="/">
<xsl:apply-templates select="/library//folder[@id=$folderID]"/>
</xsl:template>
<xsl:template match="/library//folder">
<Wib>
<xsl:value-of select="count(./file)"/>
</Wib>
</xsl:template>
</xsl:stylesheet>
HTH
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
|
I've been developing an IDL-like programming language and wrote a system of complex namespaces that cover most of core features (everything from garbage collecting to automatic serialization, dynamic casting ...). I'd like to ask how many of you feel this is a good thing to do and how many that it's a bad thing?
Software developer
MA, USA
|
|
|
|
|
Creating the language is not the problem. Support and popularity is. If no one uses the language, or close to no one, or there are better or more popular languages out there already -> what is the point of having a new language?
If your language does basically the same thing C# or VB.NET does will it actually help the community?
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi,
I have an XML file, which contains several nodes like the ones below:
<saml:Attribute AttributeName="ssbAssertionVersion" AttributeNamespace="http://www.syntegra.com">
<saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">1.0</saml:AttributeValue>
</saml:Attribute>
- <saml:Attribute AttributeName="cn" AttributeNamespace="http://www.syntegra.com">
<saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">Doe Joanna B</saml:AttributeValue>
</saml:Attribute>
----> My objective is to , take the value present inside the tag, "saml:AttributeValue " and populate it in my custom grid control, which will accept the element name as a parameter and display its value.
Problems:
1. ELEMENT NAME IS THE SAME IN ALL THE NODES, "saml:AttributeValue".
2.I dont want to reframe a new xml file out of this present one, since it increases the processing time.
3.I cant give an xpath query, directly to the my custom grid control.it will accept only the element name of a xml file.
Please help me, if you can think of a logic, that has to finally make the 'saml:AttributeValue' element name unique,without reforming a new xml so that i can directly feed that into my grid control.
Thanks In advance,
Regs, Manivannan
|
|
|
|
|
Hello
I am having problem with the for loop
here is the varialbe declaration
<xsl:variable name="client1ID" select="//clients/client/clientId" />
This shows 12345
<xsl:value-of select="$client1ID"/>
1. This works
<xsl:for-each select="//clients/client[clientId='12345']">
<xsl:value-of select="./ssn"/>
</xsl:for-each>
2. This doesn't work, it returns all ssn of all the clients
<xsl:for-each select="//clients/client[clientId=$client1ID]">
<xsl:value-of select="./ssn"/>
</xsl:for-each>
I want to know what's wrong and I want point 2 to work, using for loop, any idea.
thanks
gundappa
|
|
|
|
|
Hi there. Your variable is selecting a nodeset, not a single string value. In your first <xsl:value-of select="$client1ID" /> , you're displaying the value of the first node in the set.
In your first for-each statement, the predicate [clientId='12345'] is returning a single node, and the resulting value-of select="./ssn" XPath syntax correctly displays the value of its child ssn node.
In your second for-each statement, because the variable $client1ID is a nodeset, not a string or numeric type, it is being evaluated to the boolean value true within the predicate. The expression [clientId=$client1ID] is then evaluated as [clientId=true] ; because clientId exists as a node, the complete predicate is evaluated to true and all nodes are returned.
I think you may want to define your original variable such that it evaluates to a real string value and not a nodeset. Just a thought.
|
|
|
|
|
Thanks a lot for your response. I am new to XSL, can you please suggest how to define original variable such that it evaluates to a real string value and not a nodeset.
TIA
gund
|
|
|
|
|
Hey Mike
Thanks a lot for your suggestion, I was able to reolve it by changing the variable declaration
<xsl:variable name="client1ID"><xsl:calue-of select="//clients/client/clientId" /></xsl:variable>
and it worked!
Regards
gund
|
|
|
|