|
Starting to feel sort of responsible for your project...
I'm not sure what the problem is this time though. What's the overall goal of your transformation?
Do you want to
a) copy all the B and EM tags of some HTML to a self defined XML( or HTML) structure,
or
b) reproduce a complete HTML with all B and EM tags having a set of attributes which may be missing in the original?
When a: what's your target structure?
When b: probably a little recursion is called for.
http://www.xmlplease.com/xsltidentity
might be a good link to start with.
|
|
|
|
|
Hi and Thanks!
Frank... Your help has been fantastic, clear and precise. If not for your help I'd still be trying to copy nodes with value-of .
The article you provided solved my problem completely and was exactly what I was looking for.
However there is just one more little nagging detail.
How would I only output attributes with a value, so that all attributes such as ONCLICK="" will not be displayed?
Thanks for all your help!
MrWolfy
|
|
|
|
|
In the article they suppress the id attributes with the help of a template
<xsl:template match="@id"/>
which matches them but does nothing.
I think you're looking for something like
<xsl:template match="@*[string-length(.)=0]"/>
Haven't tried it out though; could be faulty, but I hope you get the idea.
|
|
|
|
|
Hi and Thanks!
Thanks Frank! Problem solved, that template was just what I needed to complete my project!
Thanks Again!
MrWolfy
|
|
|
|
|
I have XML that I need to tranform to another structure of XML. The XML I need to transform is below:
<ArrayNode>
<Base>
<aa>1</aa>
<bb>text</bb>
<cc>
<ccc>
<cccc>text#1</cccc>
<cccc2>text#1</cccc2>
</ccc>
<ccc>
<cccc>text#2</cccc>
<cccc2>text#2</cccc2>
</ccc>
</cc>
<dd>text</dd>
</Base>
<Base>
<aa>2</aa>
<bb>text2</bb>
<cc>
<ccc>
<cccc>text#3</cccc>
<cccc2>text#3<cccc2>
</ccc>
<dd>text</dd>
</Base>
</ArrayNode>
This needs be tranformed to:
<ArrayNode>
<Base>
<aa></aa>
<bb></bb>
<cc>
<ccc>
<cccc>Text#1</cccc>
<cccc2>Text#1</cccc2>
</ccc>
</cc>
<dd></dd>
</Base>
<Base>
<aa></aa>
<bb></bb>
<cc>
<ccc>
<cccc>Text#2</cccc>
<cccc2>Text#2</cccc2>
</ccc>
</cc>
<dd></dd>
</Base>
<Base>
<aa></aa>
<bb><bb>
<cc>
<ccc>
<cccc>Text#3</cccc>
<cccc2>Text#3<cccc2>
</ccc>
<cc>
<dd></dd>
</Base>
</ArrayNode>
Wherever <ccc> exists, it needs to loop over each <ccc> and insert each individual <ccc> into the rest of the data for that <Base> group. So if there are 3 <ccc>'s, it should repeat the entire <Base> group and insert one of the <ccc> nodes.
Thanks in advance
|
|
|
|
|
Hi All!
After the success of the help I got on my earlier post I have run into another problem.
While all my tags now work anywhere in the document below the BODY tag, my xsl:value-of in my earlier post fails to output any tags below the first one, for instance:
<B>
<EM>
Hello World!
</EM>
</B>
Only Outputs:
<B ONCLICK="" ONDBLCLICK="" ONMOUSEDOWN="" ONMOUSEUP="" ONMOUSEOVER="" ONMOUSEMOVE="" ONMOUSEOUT="" ONKEYPRESS="" ONKEYDOWN="" ONKEYUP="" ID="" CLASS="" TITLE="" STYLE="" DIR="" LANG="">
Hello World!
</B>
The EM Tags are being ignored completely, and when the tags are swapped the B tags are ignored completely.
Does anyone know why this is happening, and if so, can anyone suggest a fix or workaround?
Thanks!
MrWolfy
|
|
|
|
|
Hi All!
It has just occurred to be that my original question could have been put far more simply:
How would I output unescaped HTML tags using the xsl:value-of element, I have tried disable-output-escaping="yes" but the html tags within are just ignored and seemingly not outputted at all.
Thanks!
MrWolfy
|
|
|
|
|
Have you tried copy-of instead of value-of?
|
|
|
|
|
Hi And Thanks!
Thanks Frank! Again you have provided the soloution to a problem I have been grappling with for weeks!
Thanks Again!
MrWolfy
|
|
|
|
|
|
Don't repost your question. You were given reasonable answers on your first post.
debobrata wrote: the source code I got for the XML Notepad from the Codeplex.com is not building.
The project you describe is far to ambitious for a developer that can't even compile an open source project.
led mike
|
|
|
|
|
Hai,
i want to get the attribute names from the xml using xslt...
my xml is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
<!-- Edited by XMLSpy® -->
<catalog>
<cd select="true">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd select="true">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</catalog>
Now i want to get the value select equal to true or false..
Any one help me....
Regards,
Subbu.H
|
|
|
|
|
H.Subbulakshmi wrote: i want to get the attribute names from the xml using xslt
H.Subbulakshmi wrote: Now i want to get the value select equal to true or false..
I don't know what that means but the following XSLT will render the names of all the attributes that have the value true
<xsl:for-each select="//*/@*[.='true']">
<p>
<xsl:value-of select="name()"/>
</p>
</xsl:for-each>
led mike
|
|
|
|
|
Class declaration:
[XmlRoot(Namespace="http://www.example.com/Person")]
class Person
{
[XmlElement(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
Public string Name;
}
Serialized XML using XMLSerializer and XMLSerializerNamespace
<ns0:person xmlns:ns0="http://www.example.com/Person">
<name>Bill</name>
</ns0:person>
</pre>
I am having trouble deserializing above XML and create an instance of Person class with Name property. Also I did not find a way to pass "ns0" namespace prefix to deserialization.
Any help or direction will greatly be appreciated in any .NET compliant language.
|
|
|
|
|
Hi All!
I need to emulate the HTML <B> and <EM> tags complete with all attributes and event handlers for a little project of mine and everything works fine when these elements are seperate, Here's my xsl stylesheet:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/HTML/BODY/EM">
<EM ID="{@ID}" CLASS="{@CLASS}" TITLE="{@TITLE}" STYLE="{@STYLE}" DIR="{@DIR}" LANG="{@LANG}" ONCLICK="{@ONCLICK}" ONDBLCLICK="{@ONDBLCLICK}" ONMOUSEDOWN="{@ONMOUSEDOWN}" ONMOUSEUP="{@ONMOUSEUP}" ONMOUSEOVER="{@ONMOUSEOVER}" ONMOUSEMOVE="{@ONMOUSEMOVE}" ONMOUSEOUT="{@ONMOUSEOUT}" ONKEYPRESS="{@ONKEYPRESS}" ONKEYDOWN="{@ONKEYDOWN}" ONKEYUP="{@ONKEYUP}"><xsl:value-of select="self::EM"/></EM>
</xsl:template>
<xsl:template match="/HTML/BODY/B">
<B ONCLICK="{@ONCLICK}" ONDBLCLICK="{@ONDBLCLICK}" ONMOUSEDOWN="{@ONMOUSEDOWN}" ONMOUSEUP="{@ONMOUSEUP}" ONMOUSEOVER="{@ONMOUSEOVER}" ONMOUSEMOVE="{@ONMOUSEMOVE}" ONMOUSEOUT="{@ONMOUSEOUT}" ONKEYPRESS="{@ONKEYPRESS}" ONKEYDOWN="{@ONKEYDOWN}" ONKEYUP="{@ONKEYUP}" ID="{@ID}" CLASS="{@CLASS}" TITLE="{@TITLE}" STYLE="{@STYLE}" DIR="{@DIR}" LANG="{@LANG}" ><xsl:value-of select="self::B"/></B>
</xsl:template>
</xsl:stylesheet>
Now this works fine when <B> and <EM> are seperate, however when one tag is inside the other the result is no formatting at all!
The problem is that the match attribute of each xsl:template tag is only neing applied to B and EM tags in the BODY, is there any way I can apply the B and EM templates to the BODY and to all infinetly deeper nesting levels?
Thanks!
MrWolfy
|
|
|
|
|
MrWolfy wrote: the result is no formatting at all!
No formatting in what? A Browser? If so, looking at your XSL isn't helping us at all.
Post the HTML that is not rendering correctly and the browser version you are using.
led mike
|
|
|
|
|
<xsl:template match="/HTML/BODY/descendant::EM">
|
|
|
|
|
Hi and Thanks!
Thanks Frank! The code works perfectly! Problem Solved!
Thanks Again!
MrWolfy
|
|
|
|
|
You're welcome. In case you can read German or French, this is where I learnt it all:
http://selfhtml.org/
I hardly ever use websites in my native language when it comes to software development cause anglophone sites are abundant and (when they have a forum) well populated, but this one is so good I took it on as my default HTML and XSL reference.
|
|
|
|
|
wow, I did not understand that was what he was asking at all. Nice catch!
led mike
|
|
|
|
|
Hi,
I want to create an XML Editor Tool in C#.NET (similar to what we currently have in Visual Studio).
I want this editor tool to be integrated in my project.
The intention in creating the tool is that I want to view and edit the XML in this tool itself. I should
be able to directly modify the XML in this XML editor and thereby persist it back. And the changes should be
reflected accordingly.
It should have a collapse-Expand feature. And if possible it should also support Syntax based colours.
Hence, the tool should be able to open any XML in the proper format(proper parsing check should be there)
and edit them and save it back.
I currently work in VS 2008 in C#.
It will be really helpful if someone put the code in implementing the same and thanks in advance for any kind of suggestions.
Thanks,
Deb
|
|
|
|
|
Hi debobrata
You could use an open source text editor component called FireBall. It has features like syntax highlighting for different languages XML being one of them and it also supports collapse-expand feature. You can open any XML with file with it. As for the validation, I'm afraid you gonna have to implement that your self but the rest should be easy enough.
Regards
tptshepo
|
|
|
|
|
Hi,
Can you please provide me the link for the "FireBall" text editor component so that i can download the source code for the same. And whether the source code is available for download or not.
I was trying googling for the same, but was not able to download the source code.
Please help me in that. Atleast i need to check the editor with the source code and then i can revert you back whether it has been helpful for me or not.
Thanks and Regards,
Deb
|
|
|
|
|
|
XML Notepad[^] (from MS) is now open source. Maybe it'll help you.
|
|
|
|