473,395 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Can an xsl:function return an element w/value?

Just starting to get heavy into xslt. I'm particularly interested in xslt 2.0 and the use of regular expressions, etc.
I'm trying to figure out how I can return an element from a function. My non-xml data is very unstructured (more than I will show here) but I'm trying to see
if I can transform it into xml by putting an xml tag around it. My example data looks as follow:

<data>
pet:dog*name:tiger*
store:target*day:
wednesday*
</data>

My goal is to have the following output:
<pet>dog</pet>
<name>tiger</name>
<day>wednesday</day>
...

There many way I can parse this but, for now, I'm trying to see if I can have a function return
an element with data, such as: <pet>dog<pet>. I'm having problem putting the data
in a xsl:value-of select statement; though I'm escaping the xml angle brackets. My function looks
like the following:

<xsl:function name="my:normalizedData" as="xs:anyAtomicType*">
<xsl:param name="input"/>
<xsl:variable name="out" as="xs:anyAtomicType*">

<!-- the following express should produce: pet:doj
with regexp-group(1)=pet, gegexp-group(2)=dog -->
<xsl:analyze-string select="$input" regex="(.*?):(.*?)(?=\*)">

<xsl:matching-substring>
<xsl:value-of select="
\<regexp-group(1)\>regexp-group(2)\</regexp-group(2)\>"/>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:function>

Thank you,
Feb 19 '07 #1
1 2724
dorinbogdan
839 Expert 512MB
Hi,
Did you succeed to solve the problem ?
If yes, please let me know, in order to close the thread.
Thanks,
Dorin.
Mar 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ray Tayek | last post by:
hi, trying to use an xslt to make an xslt. trying something like: <?xml version="1.0" encoding="UTF-8"?> <?xmlspysamplexml H:\java\projects\spy1\spy\inputDocumentMap.xml?> <xsl:stylesheet...
3
by: Brynjar Glesnes | last post by:
Hi, I've browsed the Fop FAQ, usenet and the internet hoping to find a solution to my problem, but in vain. I am using Xerces 2.6.2, Xalan-J 2.6.0 and Fop 0.20-5 to create PDF-documents. In...
1
by: Matt | last post by:
For example, how to represent hyperlink in XSL? I want to add hyperlink in XSL. i.e. I need to generate <A HREF="http://mypage.html">home page</A> in HTML. I tried the following approaches but...
0
by: schaf | last post by:
Hi ! I'm writing a new xsl:function, which uses two other functions. But by the call of the first function, it would be abort just after the call. Not even the xsl:param would be set. I don't...
1
by: Wayne Lian via .NET 247 | last post by:
Hi all, Just wonder anyone have encountered this problem before?I tried using XMLSPY debugger and I can get the correct outputfor my XSLT transformation, however in .net, aftertransformation the...
1
by: Filip Hendrickx | last post by:
Hi there. I want to generate elements, choosing the element name dynamically. So I tried to use attribute value templates: <xsl:element name="{$local-name($someNode)}"> <!-- Generate element...
4
by: ina | last post by:
Hello all, I am newbie in xml and have a problem with this parse. I have this xml.file <Style> <Strategy>
3
by: bklopfen | last post by:
I am trying to create XSLT to convert XML like this: <?xml version="1.0" encoding="UTF-8"?> <sampledoc> <asdf mytoken="name1234"> <qwer>value1234</qwer> </asdf> <asdf...
1
by: IanHollamby | last post by:
I am new to XML/XSL formatting so have a fundamental question/problem. I have two formats of XML data that I require to format, the first XML file (which is under my control) uses child elements as...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.