|
Thanks alot for the effective criticism.
I overestimated (mistook) like the system had the facility to convert xml/text formats to html.
Anyway "alerted hereafter"
thanks
Fadi
|
|
|
|
|
Led,
You argued like "A Web Browser is only going to display HTML."
Was it a blind response?
When you get time, make an html file, open it in edit mode and paste plain text in that. Try viewing in a browser and you can still see the plain text (which was written without html markups).
Now try creating another .html file and paste some xml conent in that. Try viewing in a browser and you can still see the innertext of html nodes in a non formatted manner.
Can you pls. explain the reason for this w.r.t. your argument??
Also can you try the default xml given in http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog[^].
Just change the xslt content as follows
----------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="catalog/cd">
<xsl:value-of select="title"/>
<xsl:value-of select="artist"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
----------------------------
Now can you pls explain why the output is displayed in the browser even if it is in text format??
If you find a solution, can you pls. explain what is wrong with my code in the first post??
Sorry for disturbing you again
It would be nice of you, if you can convince me with a good answer
Thanks
Fadi
|
|
|
|
|
Fadi Yoosuf wrote: Now can you pls explain why the output is displayed in the browser even if it is in text format??
It's not displayed in my browser. That is why I posted what I did and it's as far as I got in debugging your error. I was wrong. Thankfully George Jackson has backed me up and hopefully provided you with the solution.
[modified]
What is wrong with this post? You asked me to explain and I did?
|
|
|
|
|
The "MySpace" element is not the child of the root node as indicated in: <xsl:template match="/"> . Also, "value-of" needs to be "xsl:value-of".
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Monday, June 1, 2009 2:12 PM
|
|
|
|
|
thank you very much George.... it is really helpful @ this situation...
led, lemme thank u also for ur efforts.(but you should understand the seriousness of misguiding someone(and all who read the post) with respect to a temporary output. there were errors in my xslt. you didn't even point out that. What if I had blindly believed you!!!!!)
|
|
|
|
|
Hi Experts,
My Xml is :
<?xml version="1.0" encoding="utf-8"?>
<Sis xsi:noNamespaceSchemaLocation="Sis.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Student>
<StudentID>1</StudentID>
<AcademicDetails>2008-2009</AcademicDetails>
<PersonalDetails>
<FirstName>Vijay</FirstName>
<MiddleName>Laxmanrao</MiddleName>
<LastName>Jadhav</LastName>
</PersonalDetails>
</Student>
</Sis>
I need to extract the value of xsi:noNamespaceSchemaLocation (ie. Sis.xsd).
How to get it ?
I have try below snippet, but it will show sXSDFile always null. Why ?
public static bool ValidateXml(Stream oXmlStream)
{
string sXsdPath = "";
string sXSDFile = "";
try
{
XmlTextReader xmlTextReader = new XmlTextReader(oXmlStream);
sXSDFile = xmlTextReader.GetAttribute("xsi:noNamespaceSchemaLocation");
}
catch (Exception ex)
{
_isValied = false;
}
return _isValied;
}
Sample code would be greatly appreciated.
Thanks.
Vijay Jadhav.
|
|
|
|
|
Hi All,
I got it.
Code snippet :
XmlTextReader xmlTextReader = new XmlTextReader(oXmlStream);
xmlTextReader.MoveToContent();
sGetXsdFileName = xmlTextReader.GetAttribute("xsi:noNamespaceSchemaLocation");
Thanks.
Vijay Jadhav.
|
|
|
|
|
Hi
How can I render the custom server side control like user controls etc using XSLT on my webpage?
|
|
|
|
|
I want to print XSLT(HTML and PDF) file, in my file has many paragraph
and i dont know how many line in paragraph. My problem is i dont want
want to print any paragraph in split pages.
Thanks
|
|
|
|
|
Copy the content of XSLT file into MSWORD and print it.
A DATAPOST COMPUTER CENTRE
(K.V Prajapati)
|
|
|
|
|
Thanks, but it not solve my solution.
|
|
|
|
|
I orginally posted this in the C# forum as I did not notice there was a xml forum...
I am trying to read an xml file into a dataset and have been met with nothing but problems.
The xml file is in the following format:
<?xml version="1.0"?><br />
<Catalog xmlns:dt="dt"><br />
<Rec><br />
<ITEM dt:dt="string"></ITEM><br />
<QTY dt:dt="string">1</QTY><br />
<SUB dt:dt="string"></SUB><br />
<CATALOG dt:dt="string">ABC123</CATALOG><br />
</Rec><br />
</Catalog>
I have tried this code in C#:
<br />
Dataset ds = new DataSet("Test");<br />
ds.ReadXML(OFD.FileName);<br />
When I set a breakpoint just after this code and examine ds, all have is a table called "Rec" and one column called "Rec_Id", clearly this is not what I want!!
Someone else has tried this and gets finds that ds has changed from "Test" to "Catalog", which is believed to have been picked up from the xml file. Expanding the Tables node reveals have 5 tables:
[0] Rec
[1] ITEM
[2] QTY
[3] SUB
[4] CATALOG
I think this can be done by specifing a schema, but I do not know how you do this whilst reading into a dataset nor do I know enough about schemas to know what to specify where!!
If I remove the dt:dt="String" datatypes then everything is fine. I do not want to manually do this so if this is the only way then how can I do it programatically? I need an automated solution.
Can anyone help?
Thanks
|
|
|
|
|
XSLT would be overkill for this.. maybe just iterate over everything and delete all dt:dt attributes?
|
|
|
|
|
I need to represent hierarchy of people who work under over persons I did it next way:
<?xml version="1.0" encoding="utf-8"?>
<person>
<name>Al</name>
<title>God</title>
<employees>
<person>
<name>Bart</name>
<title>Human</title>
<employees></employees>
</person>
<person>
<name>Lisa</name>
<title>Woman</title>
<employees></employees>
</person>
<person>
<name>Lionardo</name>
<title>Father</title>
<employees>
<person>
<name>Jim</name>
<title>Son</title>
<employees>
<person>
<name>Jim 2nd</name>
<title>Sub son</title>
<employees></employees>
</person>
</employees>
</person>
</employees>
</person>
</employees>
</person>
Is that right way to do that?
any help will appreciated!
|
|
|
|
|
Konstantin Yazvinski wrote: Is that right way to do that?
It's valid XML so if that is your requirement then yes it's right.
Or
The "right" way is dependent on your requirements. There could be many potential problems with the circular dependencies of person and employees. Well Formed XML has no problem with that but other things you might require could. Things like an ORM tool, Database Scheme or Serialization framework.
|
|
|
|
|
hi all,
i have to make a sample code using XmlDocument to select an XmlElement in this doc here is my file
<Root>
<node title="john">
</node>
<node title="Sam">
<node title="Charle">
<node title="jim"></node>
</node>
</node>
<node title="Sandra">
<node title="Amy"></node>
</node>
</Root>
and here is the method i wanna make
private static XmlElement findElement(string AttributeValue)
{
XmlDocument familyXml = new XmlDocument();
familyXml.Load("family.xml");
return siteMapXml.GetElementById(AttributeValue);// AttributeValue can be john, or jim ...
}
the problem that this method work only with ID attribute i notice wich supose that the ID is unique, how to select and XmlElement
without using an xPath because i don't know the deep of my xml tree.
thank you for help
|
|
|
|
|
I want to create one tool which will genereate the xslt...
The input will be an xml file and xslt will be generated to transofrm that xml to another....
Do anybody have any idea/code snippet/link to share?
Any help will be appreciated...
|
|
|
|
|
Any help on this one would be appreciated as it is doing my head in
As you will see by the "Current Output" I am generating unwanted translation tags containing the substring character generated in one of my for-each loops as it loops over my "Sample input"
I have a habit of getting this stuff inside out and back to front and am pretty sure the solution is staring me in the face in such an "obvious" fashion that I can't see it
The code I currently have
-----------------------------
<pre><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" indent="yes"/>
<!-- declaring 2 variables to hold "from" and "to" values -->
<xsl:variable name="from_what" select="Dictionary/@from"/>
<xsl:variable name="to_what" select="Dictionary/@to"/>
<xsl:template match="/">
<!-- hard coded task2.xsd reference -->
<Dictionary xsi:noNamespaceSchemaLocation="something.xsd" from="{$from_what}" to="{$to_what}">
<!-- outer loop to get a sorted search list -->
<xsl:for-each select="//dictionaryEntry">
<xsl:sort select="search"/>
<xsl:element name="translation">
<!-- substring the search string down to its
first character for the "initial" attribute-->
<xsl:attribute name="initial">
<xsl:value-of select="substring(search,1,1)"/>
</xsl:attribute>
<xsl:for-each select="search[not(.=preceding::search)]">
<xsl:element name="search">
<xsl:value-of select="."/>
</xsl:element>
<xsl:variable name="this_search" select="."/>
<xsl:for-each select="//dictionaryEntry[search=$this_search]">
<xsl:for-each select="replace">
<xsl:element name="replace">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</Dictionary>
</xsl:template>
</xsl:stylesheet>
</pre>
Current Output
-------------------------
<?xml version="1.0" encoding="utf-8"?>
<Dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="something.xsd" from="nl" to="es">
<translation initial="A">
<search>A Clockwork Orange</search>
<replace>La naranja mecánica</replace>
</translation>
<translation initial="A">
<search>Ab Urbe Condita</search>
<replace>Ab Urbe condita libri</replace>
<replace>Ab urbe condita</replace>
</translation>
<translation initial="A"/>
<translation initial="A">
<search>Ab Urbe Condita jaartelling</search>
<replace>Ab urbe condita</replace>
</translation>
<translation initial="B">
<search>Batman and Robin</search>
<replace>Batman y Robin</replace>
</translation>
</Dictionary>
Sample Input
---------------------
<?xml version="1.0" encoding="UTF-8"?>
<Dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="something.xsd"
from="nl"
to="es">
<dictionaryEntry>
<search>A Clockwork Orange</search>
<replace>La naranja mecánica</replace>
</dictionaryEntry>
<dictionaryEntry>
<search>Ab Urbe Condita</search>
<replace>Ab Urbe condita libri</replace>
</dictionaryEntry>
<dictionaryEntry>
<search>Ab Urbe Condita</search>
<replace>Ab urbe condita</replace>
</dictionaryEntry>
<dictionaryEntry>
<search>Ab Urbe Condita jaartelling</search>
<replace>Ab urbe condita</replace>
</dictionaryEntry>
<dictionaryEntry>
<search>Batman and Robin</search>
<replace>Batman y Robin</replace>
</dictionaryEntry>
</Dictionary>
|
|
|
|
|
hi craig,
i was wondering if you've already solved this problem? cause i too have another problem similar to this one but only has something similar with your line:
<xsl:for-each select="search[not(.=preceding::search)]">
i understand that you'll get like in your current output this line:
<translation initial="A" />
simply, how did you solve yours? (if you have solved it). i would appreciate it if you can post it. please and thanks!
modified on Sunday, April 25, 2010 12:33 AM
|
|
|
|
|
Any help on this one would be appreciated as it is doing my head in
As you will see by the "Current Output" I am generating unwanted translation tags containing the substring character generated in one of my for-each loops as it loops over my "Sample input"
I have a habit of getting this stuff inside out and back to front and am pretty sure the solution is staring me in the face in such an "obvious" fashion that I can't see it
The code I currently have
-----------------------------
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" indent="yes">
<xsl:variable name="from_what" select="Dictionary/@from">
<xsl:variable name="to_what" select="Dictionary/@to">
<xsl:template match="/">
<dictionary xsi:nonamespaceschemalocation="something.xsd" from="{$from_what}" to="{$to_what}">
<xsl:for-each select="//dictionaryEntry">
<xsl:sort select="search">
<xsl:element name="translation">
<xsl:attribute name="initial">
<xsl:value-of select="substring(search,1,1)">
<xsl:for-each select="search[not(.=preceding::search)]">
<xsl:element name="search">
<xsl:value-of select=".">
<xsl:variable name="this_search" select=".">
<xsl:for-each select="//dictionaryEntry[search=$this_search]">
<xsl:for-each select="replace">
<xsl:element name="replace">
<xsl:value-of select=".">
Current Output
-------------------------
<dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation="something.xsd" from="nl" to="es">
<translation initial="A"> <search>A Clockwork Orange
<replace>La naranja mecánica
<translation initial="A"> <search>Ab Urbe Condita
<replace>Ab Urbe condita libri
<replace>Ab urbe condita
<translation initial="A"> <translation initial="A"> <search>Ab Urbe Condita jaartelling
<replace>Ab urbe condita
<translation initial="B"> <search>Batman and Robin
<replace>Batman y Robin
Sample Input
---------------------
<dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
="" xsi:nonamespaceschemalocation="something.xsd" from="nl" to="es">
<dictionaryentry>
<search>A Clockwork Orange
<replace>La naranja mecánica
<dictionaryentry>
<search>Ab Urbe Condita
<replace>Ab Urbe condita libri
<dictionaryentry>
<search>Ab Urbe Condita
<replace>Ab urbe condita
<dictionaryentry>
<search>Ab Urbe Condita jaartelling
<replace>Ab urbe condita
<dictionaryentry>
<search>Batman and Robin
<replace>Batman y Robin
|
|
|
|
|
Hi Experts,
My Xml format is :
<Sis>
<Student>
<StudentID>1</StudentID>
<AcademicDetails>2008-2009</AcademicDetails>
<PersonalDetails>
<FirstName>Vijay</FirstName>
<MiddleName>Laxmanrao</MiddleName>
<LastName>Jadhav</LastName>
</PersonalDetails>
</Student>
</Sis>
I have seen lot of Xml's with Version information ie <? xml version="1.0" ?>.
My question is that what is a cause that my Xml didn't show version and other information.
My Sample code behind for creating Xml is :
#region Create Student Xml String
private string sCreateStudentXml()
{
try
{
Consumer.Sis studentDS = new Consumer.Sis();
Sis.StudentRow student_row = studentDS.Student.NewStudentRow();
student_row.StudentID = 1;
student_row.AcademicDetails = "2008-2009";
studentDS.Student.AddStudentRow(student_row);
Sis.PersonalDetailsRow sub_StudentPersonalDetails_row = studentDS.PersonalDetails.NewPersonalDetailsRow();
sub_StudentPersonalDetails_row.FirstName = "Vijay";
sub_StudentPersonalDetails_row.MiddleName = "Laxmanrao";
sub_StudentPersonalDetails_row.LastName = "Jadhav";
sub_StudentPersonalDetails_row.StudentRow = student_row;
studentDS.PersonalDetails.AddPersonalDetailsRow(sub_StudentPersonalDetails_row);
studentDS.AcceptChanges();
System.IO.StringWriter writer = new System.IO.StringWriter();
studentDS.WriteXml(writer, System.Data.XmlWriteMode.WriteSchema);
return writer.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
And my Xsd is :
<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio - 30 Day Trial Edition (http:
<xsd:schema id="Sis" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="StudentPersonalDetails">
<xsd:sequence>
<xsd:element name="FirstName" type="xsd:string" />
<xsd:element name="MiddleName" type="xsd:string" />
<xsd:element name="LastName" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="StudentType">
<xsd:sequence>
<xsd:element name="StudentID" type="xsd:int" />
<xsd:element name="AcademicDetails" type="xsd:string" />
<xsd:element name="PersonalDetails" type="StudentPersonalDetails" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ParentPersonalDetails">
<xsd:sequence>
<xsd:element name="FirstName" type="xsd:string" />
<xsd:element name="MiddleName" type="xsd:string" />
<xsd:element name="LastName" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ParentType">
<xsd:sequence>
<xsd:element name="ParentID" type="xsd:int" />
<xsd:element name="ParentPersonalDetails" type="ParentPersonalDetails" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Sis">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Student" type="StudentType" />
<xsd:element name="Parent" type="ParentType" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Please help! If anyone know please reply.
Note : I have created above Xml against Xsd.
Thanks.
|
|
|
|
|
Why don't you just use it as it is ? Is it causing you problems ?!
Sincerely Samer Abu Rabie
Imagination is more important than knowledge !
|
|
|
|
|
Hi Samer,
Thanks for reply.
Because the XML declaration like : xmlns:xs="http://www.w3.org/2001/XMLSchema".
I am going to use later. The purpose is to identify, Xml based on Xsd.
Any solution ?
Vijay Jadhav.
|
|
|
|
|
You can use XmlWriter with XmlWriterSettings :
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = false;
settings.Indent = true;
XmlWriter xmlWriter = xmlWriter = XmlWriter.Create(
@"c:\temp\temp.xml", settings);
studentDS.WriteXml(xmlWriter);
xmlWriter.Close();
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Tuesday, May 19, 2009 12:27 PM
|
|
|
|
|
Hi,
Thanks for your snippet.
Vijay Jadhav.
|
|
|
|