|
I just tried to reproduce your problem, but I get <img src="C:\Documents and Settings..myDir\myFile.gif"></img> even without using "disable-output-escaping".
Do you use a special encoding or xsl:output?
|
|
|
|
|
In the xsl file, I use
<xsl:output method="html">
It all started when I discovered that I have a problem when my path contains
special unicode chars, so I tried to replace all non-Alpha-Numeric characters
with their corresponding html entities.
so in VB .Net I get the unicodePath, I replace the characters I want,
and I send it as parameters to the XSL.
If there is a simpler way, I would like to know about it...
Thanks
Atara
|
|
|
|
|
(sorry, I forgot to set the Do not treat <'s as HTML tags)
In the xsl file, I use
<xsl:output method="html" />
Atara
|
|
|
|
|
I have an ASP.NET project with a String with XML in it. The XML was created from a DataSet using ds.GetXml(). Now, I want to put the contents of the 2nd column into a listbox. How can I read the string to extract the data to put it into a dataset or directly into the listbox?
Tor Solvang
|
|
|
|
|
Hi Tor,
The best way is to load the XML string into an XML document and then use XPath to retrieve the information (nodes) you want, e.g.
XmlDocument xmlReceive = new XmlDocument();
if (xmlReceive != null)
{
xmlReceive.LoadXml(xmlStringFromDataSet);
XmlNodeList collResults = xmlReceive.SelectNodes("/your/xml/tag/path/here");
if (collResults != null && collResults.Count > 0)
{
for(int i=0; i < collResults.Count; i++)
{
XmlNode nodeResult = collResults[i];
if (nodeResult != null)
{
lstBox1.Items.Add(nodeResult.text);
}
}
}
}
Replace the XPath above with the one you require.
Hope this helps,
Andy
|
|
|
|
|
you have not actually given us your REAL code - as the template would not work "<br>" in the template should be "<br/>".
if you show us the actual code we might be able to help.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Oh, sorry. I cleaned it up a little bit before posting and that small mistake slipped in. However, I already found a solution for the problem. The following template does the trick for me:
<xsl:template name="convertlinebreaks">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="contains($text,'&#xA;')">
<xsl:value-of select="substring-before($text,'&#xA;')"/>
<br/>
<xsl:call-template name="convertlinebreaks">
<xsl:with-param name="text">
<xsl:value-of select="substring(substring-after($text,'&#xA;'), 2, string-length(substring-after($text,'&#xA;')))"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
But I'd still like to know how this could be implemented using the translate() function.
|
|
|
|
|
In my XSL document I need to output some HTML if a node exists and it's not empty. I've tried testing it like this but it's not working:
<xsl:if test="'{Main/Whatever}' != ''"><br />
...<br />
</xsl:if>
It always goes into the if , no matter what. What's the solution?
Thanks,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
Is Main/Whatever supposed to be the node your checking for? If so, your comparing strings, not checking to see if the node equals an empty string. I think what your looking for is:
<xsl:if test="Main/Whatever"><br />
...<br />
</xsl:if>
|
|
|
|
|
Thanks, but this only tests if the node exists. I want it to also test if it's not empty.
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
both test can be done in one go:
<xsl:if test="string-length(Main/Whatever) > 0"><br />
...<br />
</xsl:if>
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
I have the following line in my XSL file:
<a href='mailto:YourFriend?Subject=I love XSL%26Body=How about you?'>Email to a Friend</a>
When I see the tranformed XML file in the IE6 browser, it shows the link just fine, and on the status bar I see it as:
mailto:YourFriend?Subject=I love XSL&Body=How about you?
The problem is that when I click on the link, I get this inside my Outlook popup:
To: YourFriend<br />
Cc: <br />
Subject: I love XSL&Body=How about you?
The message portion ends up as part of the subject. What's going on and how can I fix it?
By the way, I have to use %26 for the ampersand otherwise I get a "A semi colon character was expected." error, but I have a feeling that's part of the problem.
Thanks in advance,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
I am consuming one of my own webservices and i want to saw the result in datagrid.
XmlNode node = result.EndListEvents_Active(ar);
string info;
//XmlDocument doc = new XmlDocument();
//info =node.InnerXml;
//DataSet myDataSet = new DataSet();
//myDataSet.ReadXml(node.InnerText);
//myDataSet.GetXml();
// DataGrid1.DataSource = myDataSet;
// DataGrid1.DataBind();
TextBox1.Text = info;
I can see my result in "info" and in TextBox1 but not in datagrid .. how do i see my result in datagrid ... I have been trying since friday ... I will really appreciate your help ..
Thanks
|
|
|
|
|
I have the following schema, which I believe needs to be fleshed out more to make it more powerful, can someone please help and also point me in the right direction...hopefully once my project gets approved on SourceForge I will be adding this as well as something else I have to the project. Anyeverhow, here is the schema as it stands right now:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="student">
<xs:complexType>
<xs:sequence>
<xs:element name="stunum" type="xs:integer" />
<xs:element name="lastname" type="xs:string" />
<xs:element name="firstname" type="xs:string" />
<xs:element name="age" type="xs:integer" />
<xs:element name="dateborn" type="xs:date" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="address">
<xs:complexType>
<xs:sequence>
<xs:element name="pnum" type="xs:integer" />
<xs:element name="addnum" type="xs:integer" />
<xs:element name="street" type="xs:string" />
<xs:element name="city" type="xs:string" />
<xs:element name="country" type="xs:string" />
<xs:element name="poczip" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
If you can make any changes to it, please do...any and all help would be very much appreciated.
Someone said the following to me as well, although I am having problems understanding what he is implying, probably because he didn't include an example:
"In your case, it depends on where you're going with this, but I'd consider creating a ComplexType for a "person" and then define your "Student" as an extension of the Person type, adding perhaps the student ID. That way, if you added Instructor, you'd be able to re-use the generalized part of the definition of a person (since Instructors and Students both have some things in common)."
If I can get this up and running, I will eventually need to be able to easily change some things in it to get it working with a second project that I have on SourceForge.
Michael Lauzon, Founder
The Quill Society
http://www.quillsociety.org/
mlauzon@quillsociety.org
|
|
|
|
|
I haven't even tested if this is well formed so there might be some typos etc. but this modifed version from you schema shows the basic idea behind type extensions (or inheritance).
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="address" type="addressType"/>
<xs:element name="student" type="studentType"/>
<xs:element name="instructor" type="instructorType"/>
<xs:complexType name="personType">
<xs:sequence>
<xs:element name="stunum" type="xs:integer" />
<xs:element name="lastname" type="xs:string" />
<xs:element name="firstname" type="xs:string" />
<xs:element name="age" type="xs:integer" />
<xs:element name="dateborn" type="xs:date" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="studentType">
<xs:complexContent>
<xs:extension base="personType">
<xs:sequence>
<xs:element name="stunum" type="xs:integer" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="instructorType">
<xs:complexContent>
<xs:extension base="personType">
<xs:sequence>
<xs:element name="someinfo" type="xs:string" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="addressType">
<xs:sequence>
<xs:element name="pnum" type="xs:integer" />
<xs:element name="addnum" type="xs:integer" />
<xs:element name="street" type="xs:string" />
<xs:element name="city" type="xs:string" />
<xs:element name="country" type="xs:string" />
<xs:element name="poczip" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
|
|
|
|
|
Can you -- or someone -- please give me an example XML document based on the schema you posted here...so I can reference it to something.
Thanks,
Michael Lauzon, Founder
The Quill Society
http://www.quillsociety.org/
mlauzon@quillsociety.org
|
|
|
|
|
The schema itself was buggy as it had no root element and so on, but here's a refined version from it and below it you'll fin a sample xml-file. You still have to modify the schema so that it suites you purposes..
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="record">
<xs:complexType>
<xs:sequence>
<xs:element name="student" type="studentType"></xs:element>
<xs:element name="instructor" type="instructorType"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="personType">
<xs:sequence>
<xs:element name="lastname" type="xs:string"></xs:element>
<xs:element name="firstname" type="xs:string"></xs:element>
<xs:element name="age" type="xs:integer"></xs:element>
<xs:element name="dateborn" type="xs:date"></xs:element>
<xs:element name="address" type="addressType"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="studentType">
<xs:complexContent>
<xs:extension base="personType">
<xs:sequence>
<xs:element name="stunum" type="xs:integer"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="instructorType">
<xs:complexContent>
<xs:extension base="personType">
<xs:sequence>
<xs:element name="someinfo" type="xs:string"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="addressType">
<xs:sequence>
<xs:element name="pnum" type="xs:integer"></xs:element>
<xs:element name="addnum" type="xs:integer"></xs:element>
<xs:element name="street" type="xs:string"></xs:element>
<xs:element name="city" type="xs:string"></xs:element>
<xs:element name="country" type="xs:string"></xs:element>
<xs:element name="poczip" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
and here's a piece of xml which can be validated with the schema:
<?xml version="1.0" encoding="UTF-8"?>
<record
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation='schema.xsd'>
<student>
<lastname>Will</lastname>
<firstname>Smith</firstname>
<age>20</age>
<dateborn>1970-06-02</dateborn>
<address>
<pnum>235</pnum>
<addnum>234</addnum>
<street>Street</street>
<city>City</city>
<country>Country</country>
<poczip>123</poczip>
</address>
<stunum>123</stunum>
</student>
<instructor>
<lastname>John</lastname>
<firstname>Smith</firstname>
<age>20</age>
<dateborn>1960-06-02</dateborn>
<address>
<pnum>432</pnum>
<addnum>432</addnum>
<street>Street2</street>
<city>City2</city>
<country>Country2</country>
<poczip>321</poczip>
</address>
<someinfo>Some information</someinfo>
</instructor>
</record>
|
|
|
|
|
I've tried adding a simpleType to the XSD, but when I validate it using the W3C's online -- http://www.w3.org/2001/03/webdata/xsv -- XSV program I get errors...I was told to add a simpleType for a comments section, I've tried the following by adding onto the XSD you wrote here:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="record">
<xs:complexType>
<xs:sequence>
<xs:element name="student" type="studentType"></xs:element>
<xs:element name="instructor" type="instructorType"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="comment">
<xs:simpleType>
<xs:sequence>
<xs:element name="comments" type="commentType"></xs:element>
<xs:sequence>
</xs:simpleType>
</xs:element>
<xs:complexType name="personType">
<xs:sequence>
<xs:element name="lastname" type="xs:string"></xs:element>
<xs:element name="firstname" type="xs:string"></xs:element>
<xs:element name="age" type="xs:integer"></xs:element>
<xs:element name="dateborn" type="xs:date"></xs:element>
<xs:element name="address" type="addressType"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="studentType">
<xs:complexContent>
<xs:extension base="personType">
<xs:sequence>
<xs:element name="stunum" type="xs:integer"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="instructorType">
<xs:complexContent>
<xs:extension base="personType">
<xs:sequence>
<xs:element name="someinfo" type="xs:string"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="addressType">
<xs:sequence>
<xs:element name="pnum" type="xs:integer"></xs:element>
<xs:element name="addnum" type="xs:integer"></xs:element>
<xs:element name="street" type="xs:string"></xs:element>
<xs:element name="city" type="xs:string"></xs:element>
<xs:element name="country" type="xs:string"></xs:element>
<xs:element name="poczip" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="commentType">
<xs:sequence>
<xs:element name="comments" type="xs:string"></xs:element>
</xs:sequence>
</xs:simpleType>
</xs:schema>
But, as I said, I get errors when trying to validate it as you can see below:
Schema validating with XSV 2.7-1 of 2004/04/01 13:40:50
Target: file:///usr/local/XSV/xsvlog/@2379.1uploaded
(Real name: C:\Documents and Settings\bib096\Desktop\student3.xsd)
docElt: {http://www.w3.org/2001/XMLSchema}schema
Validation was strict, starting with type [Anonymous]
The schema(s) used for schema-validation had no errors
2 schema-validity problems were found in the target
--------------------------------------------------------------------------------
Problems with the schema-validity of the target
file:///usr/local/XSV/xsvlog/@2379.1uploaded:17:7: Invalid per cvc-complex-type.1.2.4: element {http://www.w3.org/2001/XMLSchema}:element not allowed here (1) in element {http://www.w3.org/2001/XMLSchema}:simpleType, expecting [{http://www.w3.org/2001/XMLSchema}:annotation,{http://www.w3.org/2001/XMLSchema}:union,{http://www.w3.org/2001/XMLSchema}:restriction,{http://www.w3.org/2001/XMLSchema}:list]:
Finite State Machine for content model
1
{http://www.w3.org/2001/XMLSchema}:annotation -> 2
{http://www.w3.org/2001/XMLSchema}:list -> 3
{http://www.w3.org/2001/XMLSchema}:restriction -> 3
{http://www.w3.org/2001/XMLSchema}:union -> 3
2
{http://www.w3.org/2001/XMLSchema}:list -> 3
{http://www.w3.org/2001/XMLSchema}:restriction -> 3
{http://www.w3.org/2001/XMLSchema}:union -> 3
3*
file:///usr/local/XSV/xsvlog/@2379.1uploaded:66:7: Invalid per cvc-complex-type.1.2.4: element {http://www.w3.org/2001/XMLSchema}:sequence not allowed here (1) in element {http://www.w3.org/2001/XMLSchema}:simpleType, expecting [{http://www.w3.org/2001/XMLSchema}:annotation,{http://www.w3.org/2001/XMLSchema}:union,{http://www.w3.org/2001/XMLSchema}:restriction,{http://www.w3.org/2001/XMLSchema}:list]:
Finite State Machine for content model
1
{http://www.w3.org/2001/XMLSchema}:annotation -> 2
{http://www.w3.org/2001/XMLSchema}:list -> 3
{http://www.w3.org/2001/XMLSchema}:restriction -> 3
{http://www.w3.org/2001/XMLSchema}:union -> 3
2
{http://www.w3.org/2001/XMLSchema}:list -> 3
{http://www.w3.org/2001/XMLSchema}:restriction -> 3
{http://www.w3.org/2001/XMLSchema}:union -> 3
3*
So, what is it that I am doing wrong?
Michael Lauzon, Founder
The Quill Society
http://www.quillsociety.org/
mlauzon@quillsociety.org
|
|
|
|
|
The way you declare the simpletype is incorrect. Check for examples from that tutorial you were pointed to in the other thread..
If I were you, I would also consider these things:
- Why do you need simpleType for the comment-element? Why not just declare it like this: <xs:element name="comment" type="xs:string"/> ?
- Should the comment-element perhaps be under the root element (record)?
- Do you really wan't to use sequences? Check what you can do for example with <xs:choise> and <xs:all> tags.. and also check the use of minOccurs and maxOccurs attributes with those elements.
|
|
|
|
|
Sub DisplayCustomer(ByVal position As Integer)
Dim node As XmlNode = xmlDoc.SelectSingleNode("/Customers/Customer[" & position & "]")
This is VB.NET. What would be the C# equivlient?
I have this so far, pero no function.
void DisplayCustomer(int position)
{
XmlNode node=xmlDoc.SelectSingleNode(@"/Customers/Customer[position]");
/\ |_ E X E GG
|
|
|
|
|
Ok, I have fixed it. For the C# version, all you have to do is replace the "&'s" with "+'s" like this...
BEFORE:
void DisplayCustomer(int position)
{
XmlNode node = xmlDoc.SelectSingleNode("/Customers/Customer[position]");
AFTER:
void DisplayCustomer(int position)
{
XmlNode node = xmlDoc.SelectSingleNode("/Customers/Customer[" + position + "]");
I guess I kinda ignored the fact that the SelectSingleNode parameter is a string. Oh well.
/\ |_ E X E GG
|
|
|
|
|
I heard that it's easier to learn the XML Schemas than it is for the XML DTD, how true is this? Also, does anyone know ehere to find a very detailed tutorial for XS but speaks to the beginner?
Thanks,
Michael Lauzon, Founder
The Quill Society
http://www.quillsociety.org/
mlauzon@quillsociety.org
|
|
|
|
|
|
i have the following tags in an .xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:js="http://www.netlink.com/schemas">
<xsl:output version="1.0" method="html"
encoding="iso-8859-1" omit-xml-declaration="yes"/>
but when i apply the .xsl to the .xml it generates the following META tag
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
which causes some problems because of the UTF-16, specifically it doesn't display correctly the accents in a site that is in spanish
any idea why is this tag being inserted even if i have a meta tag in my .xsl
thanks in advance
|
|
|
|
|
Hello, all.
When I try to parse the XML document using SAX reader method "parse" I'm have an error "E_FAIL". Why?
I'm using MSXML4. This is my XML document:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetLevelResponse xmlns="http://www.docusync.com/svc">
<GetLevelResult>
<Collection>
<File>
<Name>Test</Name>
<Size>0</Size>
<Created>0001-01-01T00:00:00.0000000+02:00</Created>
<Modified>0001-01-01T00:00:00.0000000+02:00</Modified>
<Version>0</Version>
<TimeStamp>671113</TimeStamp>
<IsDirectory>true</IsDirectory>
<HasChildFolder>true</HasChildFolder>
<Files />
<ID>40</ID>
<StorageType>Root</StorageType>
<PhysicalContainerPath />
</File>
<IsContentRequired>true</IsContentRequired>
<IsCompressed>false</IsCompressed>
<PhysicalRelativePath />
<LogicalRelativePath />
</Collection>
<HasErrors>false</HasErrors>
<ID>0</ID>
<Exceptions />
</GetLevelResult>
</GetLevelResponse>
</soap:Body>
</soap:Envelope>
Help me, please. Thanks.
|
|
|
|