|
Yes, I should use the correct names mY mistake sorry for writing it wrong and creating confusions
In below xpath a = 'http://test.com/'
/a:CustomerSearch : I get all the records [I am using Mozilla add on for XPATH checker]
/a:CustomerSearch/Results : I do not get any elements for this XPATH.
As i am not getting the results I am writing //* as xpath and use nodelist item number for reference.
Regards,
Pavas
|
|
|
|
|
For example,
take:
"<"?xml version="1.0" encoding="UTF-8"">"
"<"person">"
"<"name>Mike"<"/name">"
"<"age>12"<"/age">"
"<"/person">"
"<"ENDOFXML">"
and store it into:
struct person
{
string name;
int age;
}
so that the main program would appear as:
int main
{
person a;
a.name = "Mike";
a.age = 12;
return 0;
}
Thanks
-Mike
|
|
|
|
|
It should be pretty straightforward to write an XSL stylesheet to do this. The output type of the stylesheet would need to be Text.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Would you please show me how to do this with my small example?
I appreciate your help,
-Mike
|
|
|
|
|
Here you go.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="text" indent="yes"/>
<xsl:template match="/">
<xsl:text>int main { </xsl:text>
<xsl:apply-templates />
<xsl:text> return 0; }</xsl:text>
</xsl:template>
<xsl:template match="person">
<xsl:text>person a; a.name = </xsl:text>
<xsl:value-of select="name"/>
<xsl:text>; a.age = </xsl:text>
<xsl:value-of select="age"/>
<xsl:text>; </xsl:text>
</xsl:template>
</xsl:stylesheet>
Hope it helps.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
What does the .xml file look like?
Doesn't it have to have a reference to the .xsl file?
Do both the .xml and the .xsl have to co-exist in the same file?
Thanks,
Mike
|
|
|
|
|
Mike A. Fowler wrote: What does the .xml file look like?
Like the XML fragment you included in your original post, minus the ENDOFXML element.
Mike A. Fowler wrote: Doesn't it have to have a reference to the .xsl file?
Not necessarily. You can directly link an XML document to an XSL stylesheet by including the following declaration below your XML declaration:
<?xml-stylesheet type="text/xsl" href="mystylesheet.xsl"?>
If the XML file is viewed in a browser like IE, the browser will perform the transformation and display the result.
Mike A. Fowler wrote: Do both the .xml and the .xsl have to co-exist in the same file?
No, the XML and XSL documents reside in separate files. It wouldn't make any sense for the two to be in the same file. The stylesheet would be tightly coupled to a single XML document and couldn't be applied to other documents.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
I have one XML file that I read from sql 2005 db. I have too XSD file with the structure of XML file.
I need to deal XML versioning because is posible that the version of the XML file that I read from DB could change. I need too read the XML file according to the structure that i find in XSD file.
the XML file seems like this
<Parametri><XSD_INFO><XSD_VERSION VALUE="1.0.3.3"/><XSD_TYPE VALUE="0"/> ...
the XSD file is named Parameters_v1_0_3_3
How can I do?
Thanks.
Helen.
|
|
|
|
|
|
Hi,
I'm generating an xml dynamically and want to use xsl as a template (and therefore not generated dynamically).
Here is an example of such xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Template.xsl"?>
<PeopleList order="1">
<item>
<Name>John</Name>
</item>
<item>
<Name>Doe</Name>
</item>
</PeopleList>
<KidList order="2">
<item>
<Name>Alex</Name>
</item>
<item>
<Name>King</Name>
</item>
</KidList>
Template.xsl looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<html>
<body>
<h2>My List</h2>
<xsl:apply-templates select="KidList"/>
<xsl:apply-templates select="PeopleList"/>
</body>
</html>
</xsl:template>
<xsl:template match="PeopleList">
<p> People List </p>
</xsl:template>
<xsl:template match="KidList">
<p> KidList </p>
</xsl:template>
</xsl:stylesheet>
Result will be (the order was decided according xsl:apply-templates and not according the xml) :
My List
Kid List
People List
In the xml, PeopleList can come before KidList or after it and the order is matter - I want one xsl file that can display them in the right order.
I added an "order" attribute but still don't know if it can help and how.
Any suggestions?
|
|
|
|
|
Have you tried changing this:
<br />
<h2>My List</h2> <br />
<xsl:apply-templates select="KidList"/> <br />
<xsl:apply-templates select="PeopleList"/> <br />
to this:
<br />
<h2>My List</h2> <br />
<xsl:apply-templates select="PeopleList"/> <br />
<xsl:apply-templates select="KidList"/> <br />
Mark's blog: developMENTALmadness.blogspot.com
Funniest variable name:
lLongDong - spotted in legacy code, was used to determine how long a beep should be. - Dave Bacher
|
|
|
|
|
Thanks for replying, but this is not the solution. The xml is built dynamically so sometimes KidList will be before PeopleList and sometimes not (I can't change the xsl so I need it to be generic). The solution is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="Lists"/>
</body>
</html>
</xsl:template>
<xsl:template match="Lists">
<h2>My List</h2>
<xsl:for-each select="*">
<xsl:variable name="TemplateName" select="."/>
<xsl:apply-templates select="$TemplateName"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="PeopleList">
<p> People List </p>
</xsl:template>
<xsl:template match="KidList">
<p> KidList </p>
</xsl:template>
</xsl:stylesheet>
|
|
|
|
|
If you can't control the order of KidList and PeopleList then the result your solution will always be the order of the xml document. If KidList is first in the Xml then it will be first in your output.
If you need it to be more generic then you will need to do this:
<br />
<xsl:for-each select="*"><br />
<xsl:sort select="@order" data-type="number" /><br />
<xsl:variable name="TemplateName" select="."/><br />
<xsl:apply-templates select="$TemplateName"/><br />
</xsl:for-each><br />
<br />
That is assuming you are still using the "order" attribute in your xml that was in your first post. Otherwise you'll have to sort by the name of the element in descending order (PeopleList then KidList).
<br />
<xsl:for-each select="*"><br />
<xsl:sort select="." data-type="text" order="descending" /><br />
<xsl:variable name="TemplateName" select="."/><br />
<xsl:apply-templates select="$TemplateName"/><br />
</xsl:for-each><br />
Mark's blog: developMENTALmadness.blogspot.com
Funniest variable name:
lLongDong - spotted in legacy code, was used to determine how long a beep should be. - Dave Bacher
|
|
|
|
|
Mark J. Miller wrote: If you can't control the order of KidList and PeopleList then the result your solution will always be the order of the xml document.
Maybe I didn't explain clearly, but that is what I wanted: maintain the xml order.
I thought to add the "order" attribute for sorting, but had no idea how to use it. Your code is a great help and I will use it for sure. Thanks
|
|
|
|
|
Hello, i am serializing an arraylist and it gives such an output
<HISDepartments>
<HISDepartments>
<Aktif>69</Aktif>
<StandartDepartmentCode>213</StandartDepartmentCode>
</HISDepartments>
<HISDepartments>
<Aktif>69</Aktif>
<StandartDepartmentCode>213</StandartDepartmentCode>
</HISDepartments>
</HISDepartments>
Arraylist has 2 items, and i want an output like this
<HISDepartments>
<Aktif>69</Aktif>
<StandartDepartmentCode>213</StandartDepartmentCode>
</HISDepartments>
<HISDepartments>
<Aktif>69</Aktif>
<StandartDepartmentCode>213</StandartDepartmentCode>
</HISDepartments>
i dont want the outer tag
how can i do that can someone help?
|
|
|
|
|
aliaskain wrote: i dont want the outer tag
Without the outer tag it's not valid XML. If you are new to using XML I strongly suggest you study the subject to gain an understanding of it before you try to use it in software projects.
led mike
|
|
|
|
|
im sorry that i did not write the whole xml here
it has an outer tag like
<Abc>
......
</Abc>
in this tag it writes those that i wrote first
i wanted to say it writes 1 more tag <HISDepartments>
under Abc i want other elements
|
|
|
|
|
As part of my program I should create a XML file and it should contain a URL. That URL is containing '&' sign. Whenever I put '&' sign in XML file, Internet exploerer is not taking it and showing error
Following is a simple XML file
<pharmacy name="PChek.com" country="Canada">
<drugs>
<drug name="APO-DILTIAZ CD" unit="CAPSULE" affiliateid="https://www.interna.com/cgi-bin/ncommerce3/input?ProductName=DILTIAZ CD&groupid=RPC" ndc="" />
</drugs>
</pharmacy>
Once I open this XML file in the IE, it gives following error "
A semi colon character was expected. Error processing resource
If I remove the & sign from the url, then XML file is opening and working fine
How to solve this problem? Please let me know
|
|
|
|
|
you show encode "&" to "&" in xml
then your problem would be solved.
------------------------------------------------------------
Logiclabz
modified on Thursday, March 26, 2009 3:11 AM
|
|
|
|
|
Replace & with &
<pharmacy name="PChek.com" country="Canada">
<drugs>
<drug name="APO-DILTIAZ CD" unit="CAPSULE"
affiliateid="https://www.interna.com/cgi-bin/ncommerce3/input?ProductName=DILTIAZ
CD&groupid=RPC" ndc="" />
</drugs>
</pharmacy>
|
|
|
|
|
I am so new to the topic of XML I am sure that I will be asking the questions wrong (I feel like the South end of a horse facing North just framing my question). I have searched for a simple examples of code and have not found any simple or direct enough to meet my ability.
I am working in Excel 2003 Pro and have a multi-sheet spreadsheet that I would like to export a fixed range of data from to an XML file (this file will be used in an Xcelsius dashboard).
The data will always be on the same sheet and of the same range, though the number of records may vary from tiem to time. I could export the data to a CSV file if this would help. I would like the export to take place on a regular schedule.
Can anyone help point me at a code example?
Many thanks in advance.
a
|
|
|
|
|
abesimpson wrote: I feel like the South end of a horse facing North just framing my question
Maybe you are. I mean when I want to learn about something new to me I don't try to do it from the perspective of my project needs. I go find a tutorial or book on the subject and read it for what it is, not try to find something in it that pertains to my current project.
For tutorials on XML I recommend TopXML and www.w3schools.com web sites. For working with Excel I recommend the MSDN documentation.
led mike
|
|
|
|
|
Hi,
I originally posted this in the ASP.NET forum, to no reply and thought I would try this forum. Apologies if I am in the wrong place.
Is it possible to auto populate a word document or word document template from ASP.NET 2.0 and also have this document emailed automatically to a user? I am able to populate a word document from a datasource using xml and xslt.
I am also able to seperately email a word document as an attachment but it is the combination of creating the word document using xslt/xml and have this automatically emailed to a user that I am having difficulty with.
I'm guessing it probably can't be done and the word document would need to be saved by the user and emailed independently.
Can anyone clarify?
Thanks.
|
|
|
|
|
|
malarpm wrote: Can any body help me on this please?
Help you with what? Read these posting guidelines[^]. Pay attention to item #11.
led mike
|
|
|
|