|
my XML doc does something like this:
< list>
< listitem>
< para>some text< /para>
< block>some text< /block>
< content>some text< /content>
< list>
< listitem>
< para>some text< /para>
< /listitem>
< /list>
< /listitem>
< /list>
that is, lists contain listitems, which can contain para, block, content, and/or other lists.
i'm trying to xform that into a simple UL/LI tree, where each list starts a new UL block and each PARA, BLOCK or CONTENT is a LI within (without changing their relative order or parenting). basically, i'm making a simple HTML preview of the XML doc.
this is my original code, a little recursive template thing:
< xsl:template name="list">
< xsl:for-each select="list">
< xsl:call-template name="listitem" />
< /xsl:for-each>
< /xsl:template>
< xsl:template name="listitem">
< ul class="xsl_list">
< xsl:for-each select="para">
< li class="xsl_list_item">
< xsl:value-of select="para"/>
< xsl:call-template name="list" />
< /li>
< /xsl:for-each>
< xsl:call-template name="list" />
< /ul>
< /xsl:template>
this worked fine for that purpose, but it only pulls out PARA text. now i need to pull out the BLOCK and CONTENT tags, too (in the right order, correctly nested, etc).
so, is there a way to do a boolean match on the < xsl:for-each select="para"> , so i could select on PARA or BLOCK or CONTENT ? if not, what's the trick to doing this?
|
|
|
|
|
Yep, just use the | operator: <xsl:for-each select="para|block|content">
Logifusion[^] "This isn't a business. I've always thought of it as a source of cheap labor. Like a family."
|
|
|
|
|
ahh, great. thanks.
another question... is there a way to tell which type was matched ? i need to do this because BLOCKs need to be handled slightly differently than PARA, so i want to be able to execute different xsl:call-template's for each type.
nevermind: looks like xsl:when test="self::nodename" is what i needed.
-- modified at 15:18 Thursday 9th November, 2006
|
|
|
|
|
Chris w3schools[^] is a great resource for stuff like that.
led mike
|
|
|
|
|
yeah, i tried there (it's usually at the top of Google searches on XSL). but i couldn't find anything that helped.
|
|
|
|
|
Unfortunately, it's not organized intuitively. You may be thinking about XSL, but you have to think that if you're writing any XPath statements, you have to go to the XPath section and not the XSL section.
Logifusion[^] "This isn't a business. I've always thought of it as a source of cheap labor. Like a family."
|
|
|
|
|
i am developing a web application using asp.net 1.1 in which i provide path of a pdf file. my problem is that how to read this pdf and generate xml through it and save it into a specified folder.
please help me.
Ajeet
Ajeet Singh
|
|
|
|
|
A PDF is supposed to be a read-only document. It is either created from some other document or dynamically via some programming language. Converting it back to some other document is rather difficult! However, there are some commercial applications (and libaries, perhaps) that can convert it back with various degrees of degradation. There are probably some open-source applications or libraries that may help.
http://www.google.com/search?hl=en&q=pdf2xml[^]
|
|
|
|
|
It's a long shot and possibly totally unworkable for you but..
If you've any experience C/C++ (maybe VB could do it too) you can get an SDK off Adobe and write a plugin (add on dll file) that could do it for you.
It's about £100 for the SDK and you would need a copy of the full version of Acrobat (using a plugin with the reader requires a special license (around £10,000)).
In the plugin you can access all the text, styles, layout etc.
As I say this may be more trouble than it's worth
All the best
Tom
|
|
|
|
|
Hi all,
I need to use System.Xml instead of MSXML in IE via jscript. Is this possible? thanks.
Any suggestions or links will be help.
Ning
|
|
|
|
|
|
I have a WSDL that I am referencing with the following sequence from Visual Studio .net 2005:
<xs:element name="Name"><xs:complexType>
<xs:sequence>
<xs:element name="FirstName" type="xs:string" />
<xs:element name="LastName" type="xs:string" />
</xs:sequence>
</xs:complexType></xs:element>"
that automatically generates the classes in my vb .net project. The problem I am seeing is that when the SOAP message is generated the fields are in the wrong sequence i.e. FirstName comes after LastName and therefore causes the web service to respond with an error.
-- modified at 14:06 Wednesday 8th November, 2006
|
|
|
|
|
hi
i need to convert a html file to xml file.
please help me.
the part of html file is following:
<html>
<body>
<h2>Phonetics of the Names</h2>
<h2>
Name: <span style="color:red">mcmillan</span><br>
Phonetic: <span style="color:blue">m-ai-k-m-i-l-a-n</span><br></h2>
<h2>
Name: <span style="color:red">mike</span><br>
Phonetic: <span style="color:blue">m-aa-i-k</span><br></h2>
</html>
</body>
thanks.
|
|
|
|
|
|
thanks for reply
my xml should look like following
<?xml version="1.0"?>
<Names>
<Name>
<Spelling>mcmillan</Spelling>
<Phonetic>m-ai-k-m-i-l-a-n</Phonetic>
</Name>
<Name>
<Spelling>mike</Spelling>
<Phonetic>m-aa-i-k</Phonetic>
</Name>
</Names>
can u give me some sample code to get this format that will be more helpful for me.
thanks again.
|
|
|
|
|
No, I am not supplying you any sample code!
You can do this yourself since the HTML document is text using Regular Expressions, and string and text functions of a programming language. If you want to use the XML/XSLT libraries, you must change the HTML into an XHTML document so you can parse the HMTL using XML or transform the document using XSLT.
Or, you can load the text file into an editor and do it manually. Yes, I said it! Manually!
|
|
|
|
|
thanks for valuable suggestions.
|
|
|
|
|
Hi all i have xml file for which i have to apply xsl Using which the html should contain table formate group by one attribute name context i am getting this properly but i am having problem to display Context name above each group how to display a header or sub title using xsl like this
ContextName1 :-
here is table conataining all the data
ContextName2:-
Another Context data in table
|
|
|
|
|
< ?xml version="1.0" encoding="utf-8" ? ><br />
< ?xml-stylesheet href="mystyles.css" type="text/css" ? ><br />
< MYROOT > <!-- Rest of xml here --> < /MYROOT >
the mystyles.css file exists, but my xml won't show in Internet Explorer (it does when I remove the xml-stylesheet tag).
What is wrong here? I also found a version that replaces xml-stylesheet with xml:stylsheet, but this doesn't work either...
Many thanks..
V.
Stop smoking so you can: enjoy longer the money you save.
|
|
|
|
|
<?xml-stylesheet type ="text/css" href="mystyles.css"?>
try this i hope it should work now
|
|
|
|
|
Thanks for the reply, but it doesn't work.
the XmlDocument.Load(Stream) ; function loads it up perfectly. (this function fails if it can't parse the xml stream)
Internet Explorer 7 asks me the allow Active Content question over and over again without showing anything.
Firefox shows nothing. (but it is loaded if I view the Source)
|
|
|
|
|
mmm, my bad, it only shows the text between the tags (I only filled in attributes)
the 'Allow Active Content' warning remains though.
V.
Stop smoking so you can: enjoy longer the money you save.
|
|
|
|
|
Dears,
to apply a stylesheet into an xml document, you should use XSLT technology xml based Stylesheet.
for more information http://www.aspalliance.com/1067
Happy Coding
Best Regards,
Haissam Abdul Malak
|
|
|
|
|
Hello,
I'm trying to create a TreeView from an XmlNodeSet (which is the result of an XmlNode.SelectNodes method call). I want the TreeView to preserve the hierarchy of the XML that was queried. So as I traverse the XmlNodeSet, I need to figure out where each node should be placed in the TreeView.
The problem is, an XmlNodeSet contains no hierarchical information (as near as I can tell). So I need to take any given node, and check it against the other nodes in the XmlNodeSet, looking for ancestors. But how do I check if Node A is an ancestor of Node B? I can check if Node A is Node B's parent, but that's not good enough. Node B's parent may not have been included in the XmlNodeSet that was returned by the xpath query (XmlNode.SelectNodes). For example, Node A may be Node B's grandparent. If Node A is Node B's nearest ancestor, I want to place the TreeNode that represents Node B directly under the TreeNode that represents Node A.
So again, how can I determine if Node A is an ancestor of Node B?
I realize I can brute force this, but the only way I can think of is not very efficient. I was hoping there was an "IsAncestor" method or something, but I've had no such luck!
Any help would be greatly appreciated!
Thanks!
Ian
|
|
|
|
|
The following code may not satisfy exactly what you need. Anyway, using XPath, you can query a given node to list its ancestors. The last node in the ancestor node list is the immediate parent of the given node.
String^ xml =
L"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
L"<years>"
L" <year y=\"2003\">"
L" <month m=\"1\">"
L" <day d=\"4\"/>"
L" </month>"
L" </year>"
L" <year y=\"2002\">"
L" <month m=\"2\">"
L" <day d=\"5\"/>"
L" </month>"
L" </year>"
L" <year y=\"2001\">"
L" <month m=\"3\">"
L" <day d=\"6\"/>"
L" </month>"
L" </year>"
L"</years>";
XmlDocument^ doc = gcnew XmlDocument;
doc->LoadXml(xml);
XmlNode^ day5 =
doc->SelectSingleNode(L"/years/year/month/day[@d='5']");
XmlNodeList^ ancestors = day5->SelectNodes(L"ancestor::*");
for each (XmlNode^ ancestor in ancestors)
{
Console::WriteLine(L"{0} is an ancestor",
ancestor->Name);
}
-- modified at 10:54 Tuesday 7th November, 2006
|
|
|
|