|
savasorama wrote: or can i reach anyway?
"reach"? What does that mean?
led mike
|
|
|
|
|
Are you storing XML data in your XSL stylesheet or are you trying to run a set of XSL commands from a different place in the stylesheet?
|
|
|
|
|
I'm storing data in the xml file and transforming to the wordml via xsl. My problem is; there is font name and size declaration in the xsl and also one template that replaces string. In the xsl all <w:rPr> tags have <w:rFonts w:ascii="Arial"> but when the replace string template being called all of these fonts are ignored and it writes with the default font (Times New Roman).
Is there any way to let this not happen?
|
|
|
|
|
I'd have to see a little of your XSL to help with this. Could you provide an example of where you have the font set up and then call the "replace string" template?
|
|
|
|
|
<w:tc>
<w:tcPr>
<w:tcW w:w="1476" w:type="dxa"/>
</w:tcPr>
<w:p>
<w:pPr>
<w:rPr>
<w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/>
<wx:font wx:val="Arial"/>
<w:sz w:val="18"/>
<w:sz-cs w:val="18"/>
</w:rPr>
</w:pPr>
<xsl:variable name="value">
<xsl:call-template name="replace-string">
<xsl:with-param name="text">
<xsl:call-template name="replace-string">
<xsl:with-param name="text">
<xsl:call-template name="replace-string">
<xsl:with-param name="text">
<xsl:value-of select="obj:ClientName"/>
</xsl:with-param>
<xsl:with-param name="replace">[H]</xsl:with-param>
<xsl:with-param name="with"><b><i></xsl:with-param>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="replace">[/H]</xsl:with-param>
<xsl:with-param name="with"></i></b></xsl:with-param>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="replace">&</xsl:with-param>
<xsl:with-param name="with">&amp;</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="msxsl:node-set(elu:StringToDom($value,'true'))/*" mode="dynamic-formatting"/>
</w:p>
</w:tc>
this is the font-name declaration and template calling part..
<xsl:template name="replace-string">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="with"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$with"/>
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
<xsl:with-param name="with" select="$with"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
and this is the template.. Thanks...
Savas
|
|
|
|
|
I think your XSL is fine. It's probably got something to do with how you're organizing the WordML tags. For instance, when I see the node <w:rPr> in a WordML, it's usually inside a <w:r> instead of a <w:pPr>. I would just be checking that the WordML is correct because your XSL looks fine and shouldn't be the cause of the changing fonts.
|
|
|
|
|
Hi everybody,
I reading an XML file with the code bellow and when I want to get the value of an xml node there are also whitespaces (space, newline, tab) and the Ignore Whitespace are set to true.
Any ideea is welcome.
Dim xmlsettings As New XmlReaderSettings
With xmlsettings
.ConformanceLevel = ConformanceLevel.Auto
.IgnoreComments = True
.IgnoreProcessingInstructions = True
.IgnoreWhitespace = True
End With
Dim reader As XmlReader = XmlReader.Create(file, xmlsettings)
Dim doc As New XmlDocument
doc.Load(reader)
Dim root As XmlElement = doc.DocumentElement
Dim invoiceId As XmlNode = root.SelectSingleNode("/a/b")
biglewy
|
|
|
|
|
They hide that information in the documentation[^]
Gets or sets a value indicating whether to ignore insignificant white space.
White space that is not considered to be significant includes spaces, tabs, and blank lines
used to set apart the markup for greater readability.
led mike
|
|
|
|
|
If the spaces inside a tag are significant, it's best to enclose them in a CDATA block so they will always be preserved, for example:
<foo><![CDATA[this is
lots of
stuff...
x>]]
</foo>
|
|
|
|
|
Thanks because you reply to this question.
I think I wasn't very clear.
So, my problem is that I have an xml node like below and I want to read this node without whitespace,in my code I create an XmlReaderSettings.IgnoreWhitespace=true,
but my problem is that when I read the node I got also the whitespaces(newline,tabs) that I don't want, even if is set the xmlsettings.ignorewhitespace=true.
I read the file wiht xmlreader and after then for further processing this reader it's given to an xmldocument like this:
Dim xmlsettings As New XmlReaderSettings
With xmlsettings
.IgnoreWhitespace = True
.IgnoreComments = True
.ProhibitDtd = False
End With
Dim reader As XmlReader = XmlReader.Create(file, xmlsettings)
Dim doc As New XmlDocument
doc.PreserveWhitespace = False
doc.Load(reader)
reader.Close()
Dim root As XmlElement = doc.DocumentElement
Dim invoiceId As XmlNode = _ root.SelectSingleNode("/invoice_collection/customer_info/customer_code")
Dim customer_code = invoiceId.InnerText
<invoice_collection>
<customer_info>
<customer_code>
0006034318
</customer_code>
</customer_info>
</invoice_collection>
biglewy
|
|
|
|
|
biglewy wrote: I got also the whitespaces(newline,tabs) that I don't want, even if is set the xmlsettings.ignorewhitespace=true.
yes because as my post and the MSDN documentation explains that property is ONLY FOR WHITESPACE IN THE MARKUP .
led mike wrote: White space that is not considered to be significant includes spaces, tabs, and blank lines
used to set apart the markup for greater readability.
led mike
|
|
|
|
|
Just change your code to trim off the leading and trailing spaces:
Dim customer_code = invoiceId.InnerText.Trim()
|
|
|
|
|
I want to define a schema for an XML fiel that contains either a "Topic" or a "TopicList" which is a collection of topics.
i.e. the XML file should contain either
<?xml blubber?>
<Topic>
<!-- Topic blubber -->
</Topic>
or
<?xml blubber?>
<TopicList>
<Topic>
<!-- Topic blubber for topic 1 -->
</Topic>
<Topic>
<!-- Topic blubber for topic 2 -->
</Topic>
</TopicList>
I currently make the topic list required, but I'm curious how to avoid that.
|
|
|
|
|
peterchen wrote: but I'm curious how to avoid that.
Why would you want to? It seems your current solution is correct.
led mike
|
|
|
|
|
It's more a general question: can I check against different "top level tags" with one Schema?
All use cases I can imagine a mandatory "outer tag" solves things. But I'm doing my first "serious toying" with XML, I still don't like all these tags*, I come from a "be strict with your output, but flexible on your input" culture, and I just want to KNOW
a client once wanted 500 point curves exported as <point><X>12.34</X><Y>123.42</Y></point> in a time critical high throughput application - bno problem making them happy, but I'm still a big XML sceptic.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
It's much easier to always have the outer container tag, no matter how many tags are inside it. That way, you can enumerate all the Topics with a simple /TopicList/Topic XPath query. Don't take shortcuts on your schema just to save yourself 5 seconds of typing.
|
|
|
|
|
This is easy to do in the Schema, the software that uses it is where the complication comes in with this type of structure. Never understood why someone would want to do this, but it can be done.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="Topic">
</xs:complexType>
<xs:complexType name="TopicList">
<xs:sequence>
<xs:element type="Topic" minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="RootNode">
<xs:choice>
<xs:element type="Topic"></xs:element>
<xs:element type="TopicList"></xs:element>
</xs:choice>
</xs:complexType>
<xs:element type="RootNode"></xs:element>
</xs:schema>
Your root node is of type "RootNode", which is a Choice , meaning it will accept either a "Topic" or a "TopicList". And "TopicList" is a sequence of "Topics".
|
|
|
|
|
thanks a lot for the reply!
BoneSoft wrote: the complication comes in with this type of structure. Never understood why someone would want to do this, but it can be done.
OK OK, I get the hints
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
IMHO, if the concept of TopicList exists and the info meaningful, it should be represented explicitly.
We're the regulators that de-regulate
We're the animators that de-animate
Fold with us! ¤ flickr
|
|
|
|
|
This is my first attempt at making "real" modifications to an xsl stylesheet, and I'm completely stumped now. This is probably something simple, so try not to laugh too much.
Here's the code I'm having trouble with:
<xsl:variable name="reportName">
<xsl:value-of select="NodeName"/>
</xsl:variable>
<xsl:value-of select="$reportName"/>
<!--Does not work-->
<xsl:value-of select="//PageXML/Document/report[name = $reportName]/regionalFlag"/>
<!--Works fine-->
<xsl:value-of select="//PageXML/Document/report[name = 'workordertime']/regionalFlag"/>
Now, I'm printing the value of $reportName every time and it IS coming up as workordertime, but for some reason it isn't selecting any value. If I hardcode the report name, however, it DOES work... so the basic XSL is right. I'm fairly sure that's how I'd use a variable to do the select, as the same technique is used in other places... I have no idea what could be causing the problem...
|
|
|
|
|
Try using parameter instead of variable
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Parameters are passed into the stylesheet though right? That won't help here, I'm running through a list of reports from the source sheet, and trying to find configuration information for each report also in the source sheet... so it's not something I can just pass in on the command line.
|
|
|
|
|
You define the parameter the same way as you devine the variable.
Just write: xsl:parameter.
I have no idea, if it is passed throught stylesheets. sorry
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
I get an error saying that xsl:parameter is an invalid child element when I try to use it.
|
|
|
|
|
Sorry, it is xsl:param , not xsl:parameter
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|