|
open source XSLT file? hehehe that's a good one!
Yes I have found similar years ago by googling around. Also created my own it's not that difficult, you just use XSLT form of recursion. However the simplest mechanism is to just get the XSLT that Internet Explorer uses, it is stored in the MSXML(N).DLL. If you use Visual Studio you can open the DLL in it's resource editor and copy the XSLT which is stored as a resource right out into your own file. If I remember correctly the resource name is not obvious.
You can also embed it as a resource in your own project. I have also seen noise about people getting the resource from MSXML at runtime. That approach means you are using which ever version the user has installed on his PC so that solution might have some benefits for certain projects.
led mike
|
|
|
|
|
I’m having a problem setting up schema validation using regular expressions - I have been stuck on this for some time and would appreciate some help...
I have a set of allowed characters that I could describe using this regular expression:
[\w?\-?.?\s?\'?,?#?-[_]]
This means that I allow any alphanumeric characters and characters like dash, period, spaces, apostrophe, comma, and number (hash) symbol. The last part of the expression tries to exclude underscore since \w allows it, and my application does not like underscores.
The problem is that this is an allowed set of characters and I am using the XSD pattern facet so that I can use schema validation to find rogue characters. XSD validation fails when the expression in the pattern facet does not match. My pattern looks like this:
xs:pattern="[\w?\-?.?\s?\'?,?#?-[_]]"
This basically works except that when characters not in range are present, the expression still matches. So if I add an @ or % symbol somewhere in the data, the expression happily matches even though there is invalid data present.
I looked at groups, forward, and reverse references, conditionals, etc. I have also tried to match on characters not in the set ( like this: [^\w?\-?.?\s?\'?,?#?] ), but that does not help since the presence of disallowed characters actually causes the expression to match thereby causing schema validation to pass!
The set of allowed characters is much smaller than the set of disallowed characters, so it would not be practical to create an expression having disallowed characters.
Any advice?
Erik Westermann - wWorkflow.net - (primarily)BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453
|
|
|
|
|
Well, in case anyone is interested, I solved my problem. Schema validation turned out to be too limited to handle all cases, so now I use schema validation combined with rules in the BizTalk Rules Engine (this was part of a larger BizTalk-based solution).
So, schema validation catches more obvious, structural issues whereas the Business Rules make it easier to validate based on regular expressions, etc.
Erik Westermann - wWorkflow.net - BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453
|
|
|
|
|
Hello,
I was trying to read an xml file using C#, but it's not reading the values in the parent nodes.
I am outputting the values to a text file. I have everything in the text file except for the values in the parent nodes.
Here's some code:
newFName = fname.Substring(0, fname.Length - 4) + ".DAT";
System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath(newFName));
XmlTextReader reader = new XmlTextReader("C:\\Projects\\CSNew2\\" + fname);
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
break;
case XmlNodeType.Text:
sw.WriteLine(reader.Value);
break;
case XmlNodeType.EndElement:
break;
}
}
sw.Close();
Any ideas?
Thanks.
|
|
|
|
|
Hai all ,
i need to create(result will be xml) by using querystring
xyz.aspx?customer_id=&first_name=&last_name=&email=sun@sun.com&phone=
it will display xml like
<?xml version="1.0" encoding="utf-8"?>
<livelookup version="1.0" columns="first_name,last_name">
<customer>
<customer_id>sunnyb</customer_id>
<first_name></first_name>
<last_name></last_name>
<email>sun@sun.com</email>
<phone</phone>
<organization></organization>
<password></password>
</customer>
</livelookup>
Thanks in advance
Thanks
Subbu.
|
|
|
|
|
Hi frnds..
Im using for-each and in a particular cell i have to create link and should open other worksheet of the same workbook..
I have used generate_id function but at runtime i will not able to get the sheet name and attach the link do that sheet...
Help me out if there is any other way...
Thnks...
|
|
|
|
|
I've been wondering about this and I've been using IXMLDOMNodePtr.
Is there a difference bet. IXMLDOMNodePtr & IXMLDOMNode *? Which is better than the other??
How come the word Ptr becomes equated with * in actual code??
Any idea or any links for this info??
Thanks!
|
|
|
|
|
It's just a macro, they are the same,
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Hello alls
I am writing a program in which i need to display XML data to table row in loop, in my program i can read XML and also display it using alert() function, but i am not able to display that XML to in table row. my program code is below. Can any one help me regarding it.
function RT(str)
{
for(var i=0; i<6; i++)
{
alert(str.substring(i,1));
}
}
text = new Array();
function parseXML()
{
var module = document.getElementById('module').value;
var version = document.getElementById('version').value;
var s_key = document.getElementById('s_key').value;
var uid = document.getElementById('uid').value;
var lang = document.getElementById('lang').value;
var strUrl = 'api/index.php?module='+module+'&version='+version+'&s_key='+s_key+'&uid='+uid+'&lang='+lang;
var str_xml='';
AjaxRequest.get(
{
'url':strUrl
,'onSuccess':function(req)
{
text = req.responseText;
text = text.substring(4);
text = TrimAll(text);
alert(text);
try //Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(text);
}
catch(e)
{
try // Firefox, Mozilla, Opera, etc.
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(text,"text/xml");
}
catch(e)
{
alert(e.message);
return;
}
}
var data_node=xmlDoc.getElementsByTagName("data").item(0);
var data_node_len=data_node.childNodes.length;
for(var i=0;i<=(data_node_len/2);i++)
{
var id =data_node.getElementsByTagName("id")[i].childNodes[0].nodeValue;
// var dev_name =data_node.getElementsByTagName("device_name")[i].childNodes[0].nodeValue;
// var rep_int =data_node.getElementsByTagName("reporting_interval")[i].childNodes[0].nodeValue;
document.getElementById("device_name"+"i").innerHTML =data_node.getElementsByTagName("device_name")[i].childNodes[0].nodeValue;
document.getElementById("report_inter"+"i").innerHTML =data_node.getElementsByTagName("reporting_interval")[i].childNodes[0].nodeValue;
}
}
}
);
}
here : device_name and report_inter and that td id's where i want to show it ..... This program is not working can any one please told me where i am wrong.
Regard's
Kaushik
|
|
|
|
|
Hi,
I am just new to XSL. Hope anyone can help regarding my problem.
Problem: I only want to display the node for ITEM/DESC and ITEM1/DESC1. How to make conditions or file the xml using XSL.
THank you.
jollymj23
Sample.xsl
<xsl:for-each select="root/child" xmlns:xsl="#unknown">
<xsl:value-of select="childnode">
<xsl:for-each>
Sample.xml
<root>
<child>
<node>
<childnode>ITEM
<childnode>DESC
<node>
<childnode>ITEM1
<childnode>DESC1
<child>
<node>
<childnode>ORDER
<childnode>DESC
|
|
|
|
|
If I've got your sample correct:
<root>
<child>
<node>
<childnode>ITEM</childnode>
<childnode>DESC</childnode>
</node>
<node>
<childnode>ITEM1</childnode>
<childnode>DESC1</childnode>
</node>
</child>
<child>
<node>
<childnode>ORDER</childnode>
<childnode>DESC</childnode>
</node>
</child>
</root>
You can use XPath to filter the result:
<xsl:for-each select="//node[starts-with(string(childnode),'ITEM')]">
<xsl:value-of select="position()"/>
<xsl:text> </xsl:text>
</xsl:for-each>
This should print out 1 2 as it will select the first two node elements.
|
|
|
|
|
Hi,
I'm trying to work out how to do the following..
Within an XML data source, each <data-item> has a <countries> element containing a comma-separated list of country-codes e.g.
<data-item> <countries>GBR,ARG,IRL</countries> </data-item>
Within the XSLT I've build a lookup like...
<CountryList><Country><Code>GBR</Code><Name>United Kingdon</Name></Country></CountryList>.
I want to get a list of all the countries, in <CountryList> order, for which there are entries in one or more <countries> elements.
I've tried using exsl:node-set to build a set of nodes from the CountryList, then for-each to iterate those nodes, but can't work out how, within the for-each, to get an if test to work (somehow using contains() to see if the code for that country is within any <countries> element).
Anyone got any suggestions?
|
|
|
|
|
Hi,
i'm really new to XML, XSL
i'm trying to show a string that is Generated by a Given Loaigcal Algorithem From a JS Function
(I.E if status is Failed so Display XXXX if Passed XXYY .... )
i'm trying to give The String some Colors Like :
I'm (In blue) Trying (In Red)
any IDEA???
Have Fun
Never forget it
|
|
|
|
|
what does displaying colored text using javascript have to do with XML and XSLT?
half-life wrote: Generated by a Given Loaigcal Algorithem
What does Loaigcal mean?
led mike
|
|
|
|
|
|
1.) How do you change the the attribute value of a certain node?? Or add an attribute to a node??
Say for example:
<book id="bk112" status="New">
Then you want to change the status value to "Old" and add another attribute like Cover="SoftBound".
The IXMLDOMNode::Getattributes() can be used to get the attributes of a node. This will return a ptr to IXMLDOMNamedNodeMap. To access each attribute, the Getitem() function which will return a ptr to IXMLDOMNode. I know how to get the attributes name and value but to change it, it seems like Im stuck... I can see a setAttribute() function in IXMLDOMElement... It looks like the answer to my first question.. BUT, how am I gonna implement when the Getitem returns a ptr to IXMLDOMNode and not to IXMLDOMElement?? IXMLDOMElement inherits from IXMLDOMNode but this can't be solve by casting...
2. How can IXMLDOMNode be converted to IXMLDOMElement??
ANy ideas please?? or any solution..
Thanks!
|
|
|
|
|
SimplySane wrote: IXMLDOMElement inherits from IXMLDOMNode but this can't be solve by casting...
If you are using COM interfaces then you use COM interfaces right? QueryInterface()? However for working with the MSXML DOM in C++ I recommend using #import to generate ATL code for you. If you do then you can cast because the ATL code will perform the QueryInterface for you.
http://www.ddj.com/windows/184416877[^]
led mike
|
|
|
|
|
Yes, you're right.. I was able to cast succesfully but I got a runtime error when I tried to use the setAttribute.. Here's what I did:
IXMLDOMNodePtr pAttN = pMapAtt->Getitem( y );
IXMLDOMElementPtr pAtt;
CString csOutAttName = static_cast<LPCTSTR>( pAttN->nodeName );
CString csOutAttText = static_cast<LPCTSTR>( pAttN->Gettext() );
pAtt = (IXMLDOMElementPtr) pAttN;
BSTR bstrOutAttName = csOutAttName.AllocSysString();
pAtt->setAttribute( bstrOutAttName, static_cast<_variant_t>( csInAttText ) );
::SysFreeString( bstrOutAttName );
I've got an exception in this line:
pAtt->setAttribute( bstrOutAttName, static_cast<_variant_t>( csInAttText ) );
Looking up at setAttribute function, it has this syntax:
setAttribute(BSTR, VARIANT)
I havn't figure out what's causing the problem here and Im thinking that passing the _variant_t to a VARIANT might be the problem?? (Assuming I cast the right way..)So I've tried searching for ways on how to cast CString to VARIANT, but didn't find anything that works..
Any idea please... Thanks!
|
|
|
|
|
first why use CString unless you are manipulating the string value?
this should work
pAtt->setAttribute( pAttN->nodeName, pAttN->Gettext());
When you must have a BSTR variable prefer using _bstr_t rather than LPCSTR or
CString<br />
<br />
_bstr_t sname = pAttN->nodeName;<br />
_bstr_t svalue = pAttN->Gettext();<br />
<br />
pAtt->setAttribute(sname,svalue);<br />
Take a look at _bstr_t it has built in conversions to/from BSTRT -LPCTSTR I believe, I haven't worked with this stuff for a couple years now, but I think it's comprehensive, ctors that take either and conversion operators that get either so all you do is cast to the type you want.
led mike
|
|
|
|
|
I am trying to digitally sign an XML document in C++. Yes, I know that it is easy in .NET 2.0, but alas cannot use that!
An extract of the XML document is below.
All I am trying to do is calculate the DigestValue over the XML sub-document with Id=MsgOperation. I know that the data from this sub-document is converted into a hash with SHA-1 and then Base64.
The problem I am having is converting the sub-document using EXEC-C14N. I am trying to use the LibXML2 library (very good), to EXEC-C14N the sub-document with:
[code]
CString CDigitalCerts::C14N( const char* pszXml, const bool bExclusive )
{
CString sRet = _T("");
xmlChar* pOutput = NULL;
xmlDocPtr pXmlDoc = xmlReadMemory( pszXml, (int)strlen( pszXml ), _T("xml"), NULL, 0 );
int result = 0;
void* pData = NULL;
xmlOutputBufferPtr buf = 0;
if ( pXmlDoc )
{
result = xmlC14NDocDumpMemory( pXmlDoc,
NULL,
(int)bExclusive,
NULL,
0,
&pOutput );
}
xmlFreeDoc( pXmlDoc );
if ( result > 0 )
{
sRet = (LPCTSTR)pOutput;
}
xmlFree( pOutput );
pOutput = NULL;
return sRet;
}
[/code]
If anyone has used the xmlC14NDocDumpMemory function before from the libxml2 library and can advise what I need to add to its 2nd argv (nodes) or the 4th argv (inclusive_ns_prefixes), I would appreciate it. Or what the <ns1:operation ...="" xmlns:ns1="#unknown"> node once EXEC_C14N'ed looks like I would again be very grateful.
[code]
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ns1:Operation Id="MsgOperation" soapenv:mustUnderstand="0" xsi:type="xsd:string" xmlns:ns1="http://www.ros.ie/schemas/service/" xmlns:xsi="http://w
ww.w3.org/2001/XMLSchema-instance">CT1/File</ns1:Operation>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">
...
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#MsgOperation">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue></ds:DigestValue>
</ds:Reference>
...
</ds:SignedInfo>
<ds:SignatureValue>
</ds:SignatureValue>
<ds:KeyInfo>
<wsse:SecurityTokenReference>
<wsse:Reference URI="#X509Token"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature></wsse:Security> </soapenv:Header>
[/code]
|
|
|
|
|
Andy H wrote: If anyone has used the xmlC14NDocDumpMemory function before from the libxml2 library
No, I have never used the libxml2 library.
Andy H wrote: can advise what I need to add to its 2nd argv (nodes) or the 4th argv (inclusive_ns_prefixes),
Does this help[^]?
led mike
|
|
|
|
|
Well what was the point of your reply? How f******* stupid.
|
|
|
|
|
Andy H wrote: Well what was the point of your reply?
The point was the link I supplied that appears to define the parameters you asked about, you f***ing moron. F*** off a**hole.
led mike
|
|
|
|
|
I am very sorry, I did not spot the link in your reply.
Thanks, but I have seen the page you referred to.
|
|
|
|
|
Andy H wrote: I am very sorry, I did not spot the link in your reply.
Oh, ok, no problem, simple mistake, I make them all the time, I even make complicated mistakes.
Andy H wrote: Thanks, but I have seen the page you referred to.
Ok then I need more specific information about what you need to know.
nodes : Is a NodeSet that will act like a filter so that it will only dump those nodes rather than the entire document.
inclusive_ns_prefixes : Is a string array of the namespaces, where the last element of the array is NULL.
Based on the doc you can pass NULL for both of those and it should still work.
led mike
|
|
|
|