|
Thanks a ton for the advice!
i will work on the Xml repair API, hope it would be usefull in other cases too!
i l get back once i comeplete the thing!
Thanks!
|
|
|
|
|
Hi
I wanted to ask:
Is this possible to create a new XML file based on another XML file using XSL/XSLT?
I'm trying to build an application that can provide filtering capabilities in an XML file. I want to show the file in a TreeView such that the nodes should show the text inside the XML Tags and not the 'tag Element text'...
Thanks in advance
Rocky
|
|
|
|
|
Rocky71 wrote: Is this possible to create a new XML file based on another XML file using XSL/XSLT?
Yes, you would usually use xsl:copy and/or xsl:copy-of .
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hello,
I setup SharePoint services 3 at work so I can use its helpdesk capabilities. The problem is I want to track the number of closed service tickets for each technician. There is a built in Web Part that displays the initiated, engaged, resolved, and closed tickets. I want to add a bar for each technician that will display each of our closed tickets. The web part looks like this below. A little over half way down shows the bars where each condition will be displayed. I just want to copy a piece of that code and make a change to add the technician's closed tickets. Can anyone assist me with this?
Thanks!!
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns ="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:WebControls="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns ="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:WebControls="Microsoft.SharePoint.WebControls">
<xsl:call-template name="dvt_1"/>
</xsl:template>
<xsl:template name="dvt_1">
<xsl:param name="ParentPath"/>
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
<xsl:variable name="dvt_RowCount" select="count($Rows)" />
<xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
<xsl:call-template name="dvt_1.footer">
<xsl:with-param name="Rows" select="$Rows" />
</xsl:call-template>
</xsl:template>
<xsl:template name="percentformat">
<xsl:param name="percent"/>
<xsl:choose>
<xsl:when test="format-number($percent, '#,##0%;-#,##0%')= 'NaN'">0%</xsl:when>
<xsl:otherwise>
<xsl:value-of select="format-number($percent, '#,##0%;-#,##0%')" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="ChartRow">
<xsl:param name="RowName"></xsl:param>
<xsl:param name="Value"></xsl:param>
<xsl:param name="PercentValue"></xsl:param>
<tr>
<td class="ms-formbody" width="125px" style="vertical-align:middle">
<xsl:value-of select="$RowName"/>: <xsl:value-of select="$Value" />
<xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&nbsp;
</xsl:text>(<xsl:call-template name="percentformat"><xsl:with-param name="percent" select="$PercentValue"/></xsl:call-template>)
</td>
<td>
<table width="100%" >
<tr>
<td width="{round($PercentValue*100)+1}%" height="15px" class="ms-selected">
<xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&nbsp;</xsl:text>
</td>
<td width="100%" >
<xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&nbsp;</xsl:text>
</td>
</tr>
</table>
</td>
</tr>
</xsl:template>
<xsl:template name="dvt_1.footer">
<xsl:param name="ParentPath" />
<xsl:param name="Rows" />
<xsl:variable name="NotStarted" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Status) = 'Initiated'])" />
<xsl:variable name="InProgress" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Status) = 'Engaged'])" />
<xsl:variable name="Completed" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Status) = 'Resolved'])" />
<xsl:variable name="Deferred" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Status) = 'Closed'])" />
<xsl:variable name="AllTasks" select="count(/dsQueryResponse/Rows/Row)" />
<xsl:variable name="percentNotStarted" select="$NotStarted div $AllTasks" />
<xsl:variable name="percentInProgress" select="$InProgress div $AllTasks" />
<xsl:variable name="percentCompleted" select="$Completed div $AllTasks" />
<xsl:variable name="percentDeferred" select="$Deferred div $AllTasks" />
<table width="100%" cellspacing="0" cellpadding="2" style="border-right: 1 solid #C0C0C0; border-bottom: 1 solid #C0C0C0; border-left-style: solid; border-left-width: 1; border-top-style: solid; border-top-width: 1;">
<xsl:call-template name="ChartRow">
<xsl:with-param name="RowName">Initiated</xsl:with-param>
<xsl:with-param name="Value"><xsl:value-of select="$NotStarted"/></xsl:with-param>
<xsl:with-param name="PercentValue"><xsl:value-of select="$percentNotStarted"/></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="ChartRow">
<xsl:with-param name="RowName">Engaged</xsl:with-param>
<xsl:with-param name="Value"><xsl:value-of select="$InProgress"/></xsl:with-param>
<xsl:with-param name="PercentValue"><xsl:value-of select="$percentInProgress"/></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="ChartRow">
<xsl:with-param name="RowName">Resolved</xsl:with-param>
<xsl:with-param name="Value"><xsl:value-of select="$Completed"/></xsl:with-param>
<xsl:with-param name="PercentValue"><xsl:value-of select="$percentCompleted"/></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="ChartRow">
<xsl:with-param name="RowName">Closed</xsl:with-param>
<xsl:with-param name="Value"><xsl:value-of select="$Deferred"/></xsl:with-param>
<xsl:with-param name="PercentValue"><xsl:value-of select="$percentDeferred"/></xsl:with-param>
</xsl:call-template>
</table>
</xsl:template>
<xsl:template name="dvt_1.header">
<xsl:param name="ParentPath" />
<xsl:param name="Rows" />
<table cellSpacing="0" cellPadding="2" border="0" width="365px" >
<tr>
<td class="ms-formfieldlabel">
<p>
<strong>Overall Task Status</strong>
</p>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
|
|
|
|
|
How can i insert data from textbox into xml datatype column using asp.net? Also how can i select the data from xml datatype in the datagrid?
Any one can help me plz....
|
|
|
|
|
Hi,
Without going into the complexity of Schema you could do the following:
INSERT INTO TableName values('lt root /gt')
lt = <
gt = >
Note: the value should be a valid XML documents or XML fragment (e.g. an XML document that doesn't have a root)
for more information about XML, you can try this website http://jameleon.sourceforge.net/xmlBasics.html[^]
about getting XML from datagrid, sorry I didn't understand your question, please explain it more.
Hope this helps
|
|
|
|
|
i want to insert data from textbox into xml datatype column in database.
i tried the coding for this... But it accepts the data with tags( Root> ).If we enter without the tag, it is showing error.
|
|
|
|
|
hello,
I am new to both the xml and C#.net technologies. I am generating a xml file in c#.net.I am trying to generate a xml file whose first/root node should look like this:
<tns:schedule xmlns:tns="http://www.sample.com/Schedule" xmlns:dt="http://www.sample.com/DataTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sample.com/Schedule Schedule.xsd" scheduleType="Playback" version="1.0" creationTime="2006-01-29T00:00:00" originator="sample">
<scope startTime="2006-01-29T04:00:00" stopTime="2006-01-29T06:00:00" />
I am using the xmlWriter class to generate the xml. The data for xml is taken from the structure which is filled by the program itself.
<u>My code is as follows:</u>
private void generateXml()
{
TreeNode tempNode,selectedNode;
frmFindByProgram.stProgram stTemp = new frmFindByProgram.stProgram();
selectedNode=new TreeNode();
tempNode = new TreeNode();
XmlTextWriter writer = new XmlTextWriter("E:\\Projects\\Project1\\July\\26\\ScheduleDemo\\NewXML.xml", new System.Text.UTF8Encoding());
//Write the header information
writer.WriteStartDocument();
//Write the root node
writer.WriteStartElement("tns", "schedule","http://www.sample.com/Schedule");
//use the record structure
int i = 0, count;
count = xmlSlotNodes.Count;
// sort the slots according to there callSign
xmlSlotNodes.Sort(0,count,new Sorting ());
string[] prgmTime = new string[2];
stTemp = (frmFindByProgram.stProgram)xmlSlotNodes[i];
selectedNode=getClickedNode();
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("CruiseLine");
// writer.WriteAttributeString("Id", selectedNode.Text );
writer.WriteAttributeString ("Name",selectedNode.Parent.Text);
writer.WriteStartElement("Ship");
writer.WriteAttributeString("Name", selectedNode.Text );
writer.WriteStartElement("Channel");
writer.WriteStartElement("CallSign");
writer.WriteAttributeString("Value", stTemp.CallSign);
prgmTime = stTemp.Duration.Split('-');
do
{
stTemp = (frmFindByProgram.stProgram)xmlSlotNodes[i];
prgmTime = stTemp.Duration.Split('-');
writer.WriteStartElement("Program");
writer.WriteAttributeString("Id", stTemp.ProgramID);
writer.WriteAttributeString("Title", stTemp.Title);
writer.WriteAttributeString("AssetName", stTemp.AssetName);
writer.WriteAttributeString("StartTime", prgmTime[0].ToString());
writer.WriteAttributeString("EndTime", prgmTime[1].ToString());
writer.WriteEndElement();
//Write some white space between nodes
writer.WriteWhitespace("\n");
tempNode =selectedNode;
selectedNode = getClickedNode();
-----
-----
---
writer.close();
}
<u>my output file, NewXML.xml file contains the following </u>:
<?xml version="1.0" encoding="utf-8" ?>
- <tns:schedule xmlns:tns="http://www.sample.com/Schedule" >
- <CruiseLine Name="Carnival">
- <Ship Name="Celebration">
- <Channel>
- <CallSign Value="ABC">
<Program Id="104" Title="assde4" AssetName="asset4" StartTime="01:30" EndTime="02:00" />
</CallSign>
......
</tns:schedule>
<u>In order to modify the root/first node's information as given in the my sample file....</u>
i added new line to the code that is at:
//Write the root node
writer.WriteStartElement("tns", "schedule","http://www.sample.com/Schedule");
writer.WriteAttributeString("dt",null,"http://www.sample.com/DataTypes");
- <tns:schedule d1p1:dt="" xmlns:d1p1="http://www.sample.com/DataTypes" xmlns:tns="http://www.sample.com/Schedule">
i don't know from where this d1p1 got inserted and also why this attribute instead of getting appended is becoming the first attribute of the root element.
Please can anyone help me out.I am trying it from last 4 days.. please try to help me soon.
Thank you.
Anee
<u></u>
Anee
|
|
|
|
|
I am writing the following code for creating the XML file.
HRESULT hr;
IXMLDOMDocumentPtr pXMLDoc = NULL;
CoInitialize(NULL);
hr=pXMLDoc.CreateInstance("msxml2.domdocument");
IXMLDOMNodePtr pRootNode= NULL;
IXMLDOMNodePtr pRecNode= NULL;
IXMLDOMNodePtr pRecNode1= NULL;
IXMLDOMElementPtr pElement=NULL;
_variant_t varNodeType((short)MSXML2::NODE_ELEMENT);
hr= pXMLDoc->createNode(varNodeType,
_T("RTCS"), _T("Remote Target Control System"),&pRootNode);
hr=pXMLDoc->createElement(_T("Connection"),&pElement);
IXMLDOMAttributePtr pRecIdAttr = NULL;
IXMLDOMNamedNodeMapPtr pattributeMap;
hr=pXMLDoc->createAttribute(_T("connect"),&pRecIdAttr);
hr=pRecIdAttr->put_nodeTypedValue(_variant_t(_T("connect_val")));
hr=pElement->get_attributes(&pattributeMap);
hr=pattributeMap->setNamedItem(pRecIdAttr,&pRecNode);
hr=pXMLDoc->appendChild(pRootNode,&pRecNode);
but i am not able to see the child node created in the xml file.Only root node is created:
The xml file i want to create is:
?xml version="1.0"?>
<rtcs name="Remote Target Control System">
<Connection connect= "connectval" ipaddress = "ip_addresss" Port = "port_number"/>
<Logging Directory="path" Level="level" ComPort="port_number" Maxsize="max_size"/>
<Video BitRate="bitrate" InputType="input_type" Preview="preview" FrameDrop="frame_drop" Dumping ="dump"/>
<IR directory_path="dir_path"/>
</rtcs
|
|
|
|
|
I have the following webservice which gets a xml payload I would like to take that payload validate it against a schema then send it to websphere MQ. I have a good portion working but when I write the payload to MQ its empty almost like I am not able to get the information being sent in. Here is the code I am using and any help would be great as I have hit a road block and still pretty new to all this.
/// <remarks>
[System.Web.Services.Protocols.SoapHeaderAttribute("payloadManifest", Direction=System.Web.Services.Protocols.SoapHeaderDirection.InOut)]
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://arknet.arkona.com/wsTransport/service/ProcessMessage", RequestNamespace="http://www.starstandards.org/webservices/2005/10/transport", ResponseNamespace="http://www.starstandards.org/webservices/2005/10/transport", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Binding="starTransport")]
public virtual void ProcessMessage([System.Xml.Serialization.XmlElementAttribute(ElementName="payload")] ref Payload payload)
{
//Here is the Code that reads the XML Payload Stream and Validates it to the correct Schema before sending the message forward.
//System.Xml.XmlElement xe = payload.content[0].Any;
//XmlDocument xmlDoc = xe.OwnerDocument;
//xmlDoc.Schemas.Add(null, "http://localhost/wsTransport/ProcessCRM.xsd");
//xmlDoc.Validate(delegate(object sender, ValidationEventArgs vargs)
//{
// Console.WriteLine("{0}: {1}", vargs.Severity, vargs.Message);
//}, xe);
System.Xml.XmlElement xe = payload.content[0].Any;
XmlDocument xmlDoc = xe.OwnerDocument;
string qManager = "ARKDEV.QUEUE.MANAGER";
string channel = "SYSTEM.ADMIN.SVRCONN";
string hostName = "arkdev.arkona.com";
string qName = "ROB.IN.QUEUE";
MQEnvironment.Hostname = (hostName);
MQEnvironment.Channel = (channel);
MQEnvironment.Port = 1414;
try
{
MQQueueManager qMgr = new MQQueueManager(qManager);
MQQueue queue = qMgr.AccessQueue(qName, MQC.MQOO_OUTPUT);
MQMessage msgData = new MQMessage();
msgData.WriteString(xmlDoc.OuterXml);
MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.Put(msgData, pmo);
queue.Close();
qMgr.Close();
}
catch (MQException e)
{
Console.WriteLine("Error: {0}", e.ToString());
}
}
Thanks for taking the time to look at this and any help would be great
|
|
|
|
|
Hi Guys,
I am not that good with xPath, so please don't laugh at my question
Trying to query an XmlNode to find a given element's parent's attribute...
For example:
<root>
<parent name="Mom">
<kid>Mike</kid>
<kid>Rose</kid>
</parent>
</root>
Basically, I'm trying to find the name of "Mike's" parent (Mom). If you can help me out, thank you so much... thousand kisses to you!
Grapes
|
|
|
|
|
You use parent::node() :
using namespace System;
using namespace System::Xml;
int main(array<System::String ^> ^args)
{
String^ xmlString =
"<root>"
" <parent name=\"Mom\">"
" <kid>Mike</kid>"
" <kid>Rose</kid>"
" </parent>"
"</root>";
XmlDocument^ xmlDoc = gcnew XmlDocument;
xmlDoc->LoadXml(xmlString);
XmlNodeList^ children = xmlDoc->SelectNodes("/root/parent/kid");
for each (XmlNode^ child in children)
{
XmlNode^ parent = child->SelectSingleNode("parent::node()");
if (parent != nullptr)
{
Console::WriteLine("{0}'s parent is good old {1}.", child->InnerText,
parent->Attributes->GetNamedItem("name")->Value);
}
}
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks alot George!!
Grapes
|
|
|
|
|
Hello,
I got the following in my XML Settings file:
<configuration>
<appSettings>
<add key="CAPTURE_DEVICE" value="@device:pnp:\\? pci#ven_109e&dev_036e&subsys_13eb0070&rev_11#4&1b02cb0b&0&10f0#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global" />
</appSettings>
</configuration>
I want to read the value of the capture device from the xml file into a string variable. But due to the "&" the value = "...." doesnt seem to be a valid string. Is there a way to handle this?
thx in advance,
best regards
dominik
|
|
|
|
|
& has to be escaped as &
|
|
|
|
|
It's a good thing he came here to find that out. It's not like there is a freely available documented standard on the internet that contains that information... wait
|
|
|
|
|
Thanks for your answer!
But is there a way to get a valid string without manually editing the original string and replacing every & with &amp;?
regards
Dominik
-- modified at 4:29 Friday 27th July, 2007
|
|
|
|
|
No because having an unescaped & is what makes it invalid XML.
|
|
|
|
|
Hi,
I am a newer to XML and Visual C++.
Could You please say, How is the Data from XML file is read/ or written to through Visual C++ program??
Gyan
|
|
|
|
|
There are two Microsoft solutions: MSXML and XmlLite. You can find documentation and samples on http://msdn2.microsoft.com/en-us/default.aspx[^] or just use a search engine such as Google.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Can Some please help me.
How can we update a value which has the same parameter name in the same section using vc++
<rootelement>
<param1>Param Value
<param1>Param Value
<rootelement>
Now i want to update both the param values but both the parameters has the same parameter name. So how can we update these values??
Thanks
|
|
|
|
|
You can use document order. To locate the first "Param1" element, the XPath is: /RootElement/Param1[1] and the second is: /RootElement/Param1[2] .
George
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi,
well I\m a completely newbie in XML and I've been given a task to put a filtering capability on an XML document in .NET application. So I'm looking at XPath for that. Now I wanna populate a combo box with all the names of the XML elements i.e tags so that I can populate the treeView on that basis.
Now to populate that combobox I was thinking if I can make an XPath Query that can give me the unique namesof the tags. Is this possible that way or do I have to get all teh elements first and then filter out the unique ones
thanks in advance
Rocky
|
|
|
|
|
Say I have this XML Document:
<?xml version="1.0" encoding="UTF-16"?>
<?xml-stylesheet type="text/xsl" href="MyXsl.xsl"?>
<page>
<para>
Test paragraph.
</para>
<para>
Test <link href="codeproject.com">link</link>.
</para>
</page>
In XSLT, how would you change <link href into <a href ?
I have this so far...
<xsl:template match="/">
...
<xsl:for-each select="//para">
<xsl:call-template name="paragraph"/>
</xsl:for-each>
...
</xsl:template>
<xsl:template match="//para" name="paragraph">
<p>
<xsl:value-of select="."/>
</p>
</xsl:template>
Thanks! I've tried Google, but couldn't find anything useful.
|
|
|
|
|
I hope the following will give you some ideas:
<?xml version="1.0"?>
<page>
<para>
Test paragraph
</para>
<para>
A good place to find source code is <link href="http://www.codeproject.com">CodeProject</link>
</para>
</page>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/page">
<xsl:apply-templates select="para"/>
</xsl:template>
<xsl:template match="para">
<p><xsl:apply-templates select="child::text() | link"/></p>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="link">
<a href="{@href}"><xsl:value-of select="."/></a>
</xsl:template>
</xsl:stylesheet>
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|